After Mid-Terms
Design Pattern
Adapter design pattern
• Adapter pattern works as a bridge between two incompatible
interfaces. This type of design pattern comes under structural pattern
as this pattern combines the capability of two independent interfaces.
• An Adapter Pattern says that just "converts the interface of a class
into another interface that a client wants".
• In other words, to provide the interface according to client
requirement while using the services of a class with a different
interface.
• The Adapter Pattern is also known as Wrapper.
Components
• We have 4 components:
• Target: Domain-specific interface requested by the Client.
• Client: Applies business logic, and collaborates with the target.
• Adaptee: The interface which is incompatible with the target. Needs
adaptor.
• Adapter: The compatibility object between the Adaptee and the
Target.
Bridge Design Pattern
• Bridge is used when we need to decouple an abstraction from its
implementation so that the two can vary independently. This type of
design pattern comes under structural pattern as this pattern
decouples implementation class and abstract class by providing a
bridge structure between them.
• Key Components and Concepts
• The Bridge Design Pattern comprises the following key components:
• Abstraction: This class defines the high-level logic and holds a reference
to the implementation. It declares methods that are meaningful to clients.
• Refined Abstraction: A concrete subclass of Abstraction that further
customizes the abstraction's behavior.
• Implementation: This interface declares methods that are implemented
by concrete implementations. It focuses on low-level details.
• Concrete Implementation: These classes provide actual implementations
of the methods defined in the Implementation interface.