NEW
Font size
WorksheetsStructural and Behavioral Design Patterns
Total questions: 20
Worksheet time: 16mins
Purpose Defines an abstract object structure independently of the implementation object structure in order to limit coupling.
Use When
Abstractions and implementations should not be bound at compile time.
Adapter
Bridge
Convert the interface of a class into another interface clients expect and let classes work together, that could not otherwise because of incompatible interfaces.
Bridge
Adapter
Composite
Observer
Represents an operation to be performed on the elements of an object structure. This Pattern lets you define a new operation without changing the classes of the elements on which it operates.
Bridge
Mediator
Observer
Visitor
Permits classes with disparate interfaces to work together by creating a common object by which they may communicate and interact.
Use When
A class to be used doesn’t meet interface requirements.
Adapter
Bridge
Compose objects into tree structures to represent part-whole hierarchies. / Composite lets clients treat individual objects and compositions of objects uniformly.
Bridge
Adapter
Composite
Observer
Purpose Defines an abstract object structure independently of the implementation object structure in order to limit coupling.
Use When
Abstractions and implementations should be independently extensible.
Adapter
Bridge
Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
Strategy
Mediator
Observer
Adapter
A billing application needs to interface with an HR application in order to exchange employee data, however each has its own interface and implementation for the Employee object. In addition, the SSN is stored in different formats by each system.
What pattern can we use to create a common interface between the two applications that allows them to communicate using their native objects and is able to transform the SSN format in the process?
Adapter
Bridge
Chain of Responsibility
Observer
Permits classes with disparate interfaces to work together by creating a common object by which they may communicate and interact.
Use When
Complex conditions tie object behavior to its state.
Adapter
Bridge
It decouples an abstraction from its implementation so that the two can vary independently.
Is it about Bridge Pattern?
True
False
Purpose Defines an abstract object structure independently of the implementation object structure in order to limit coupling.
Use When
Changes in the implementation of an abstraction should have no impact on clients.
Adapter
Bridge
Allows objects with incompatible interfaces to work together.
Is it about Adapter Pattern?
True
False
Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
Bridge
Mediator
Observer
Adapter
Permits classes with disparate interfaces to work together by creating a common object by which they may communicate and interact.
Use When
Transitions between states need to be explicit.
Adapter
Bridge
• When you want to use a class that's interface isn't compatible with your code.
• When you want to use subclasses that lack common functionality and can't be added to the superclass.
Use ________________ Pattern
Adapter
Bridge
Chain of Responsibility
Command
Purpose Defines an abstract object structure independently of the implementation object structure in order to limit coupling.
Use When
Implementation details should be hidden from the client
Adapter
Bridge
Define an object that encapsulates how a set of objects interact. This Pattern promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently.
Bridge
Mediator
Composite
Adapter
The implementation of the Adapter Pattern decreases the complexity of the code because you need not introduce new interfaces.
True
False
It avoids attaching the sender of a request to its receiver, giving this way other objects the possibility of handling the request too.
Bridge
Adapter
Composite
Chain of Responsibility
Encapsulate a request in an object, Allows the parameterization of clients with different requests and Allows saving the requests in a queue.
Bridge
Command
Composite
Adapter
