Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

What is difference between Adapter and Bridge pattern?

Sumit Rawal answered on May 13, 2023 Popularity 3/10 Helpfulness 1/10

Contents


More Related Answers

  • What is a Bridge Design Pattern?
  • Bridge Pattern

  • What is difference between Adapter and Bridge pattern?

    0

    The Adapter and Bridge design patterns are used to decouple an abstraction from its implementation. However, there are some differences between them.

    The Adapter pattern is used to convert the interface of a class into another interface that the client expects. It allows two or more incompatible interfaces to work together.

    The Adapter pattern can be used when we have an existing class, and we want to use it with other classes that have a different interface. We create an adapter class that implements the target interface and uses the existing class to implement the interface methods.

    The Bridge pattern is used to separate the abstraction from its implementation so that they can vary independently. It is used when we want to change the implementation of a class without affecting its interface.

    The Bridge pattern consists of two layers of abstraction: the abstraction layer and the implementation layer. The abstraction layer provides the high-level interface, and the implementation layer provides the low-level implementation details.

    In summary, the Adapter pattern is used when we want to make two incompatible interfaces work together, while the Bridge pattern is used when we want to separate the interface from its implementation.

    Popularity 3/10 Helpfulness 1/10 Language whatever
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on May 13 2023
    Sumit Rawal
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.