Design Pattern - Structural Flashcards

1
Q

Adapter

A

Works as a bridge between two incompatible interfaces. Involves a single class that is responsible to join functionalities of independent or incompatible interfaces.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Bridge

A

Used when we need to decouple an abstraction from its implementation so that the two can vary independently. Involves an interface that acts as a bridge making the functionality of concrete classes independent from interface implementer classes. Both types of classes can be altered structurally without affecting each other.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Composite

A

Used where we need to treat a group of objects in a similar way as a single object. Composes objects in terms of a tree structure to represent part as well as whole hierarchy. Creates a class that contains a group of its own objects. This class provides ways to modify its group of same objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Decorator

A

Allows a user to add new functionality to an existing object without altering its structure. Creates a decorator class that wraps the original class and provides additional functionality keeping class methods signature intact.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Facade

A

Hides the complexities of the system and provides an interface to the client using which the client can access the system. Involves a single class that provides simplified methods required by client and delegates calls to methods of existing system classes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Flyweight

A

Primarily used to reduce the number of objects created and to decrease memory footprint and increase performance. Tries to reuse already existing similar kind objects by storing them and creates new object when no matching object is found.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Private Class Data

A

Prevents manipulation of data that is meant to be immutable by separating the data from the methods that use it into a class that maintains the data state. Used to encapsulate class attributes and their manipulation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Proxy

A

A class represents functionality of another class. Creates a object having original object to interface its functionality to outer world.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly