Design Pattern Flashcards

1
Q

Composite Design Pattern

A

Compose objects into tree structures that represent whole-part hierarchies

Composite lets clients treat individual objects and compositions of objects uniformly

This pattern is a partitioning design pattern

Allows a group of objects to be treated the same way as a single-instance of an object

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

Data Transfer Object Design Pattern

A

Rather then force a Facade class to maintain a large interface to support domain composed of a large number of data attributed.
The Facade encapsulates the key data of a domain object in a simple class (the Data Transfer Object) and returns the DTO object (not individual data elements) to clients
In this way, one call to the Façade is needed to get all the data that the Façade is willing to give for a domain object.
Without using this pattern, many calls might be needed to access the key data of a domain object needed to perform a particular function.

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

Decprator Design Pattern

A

provides a flexible alterative to sub-class for extending functionality
Inheritance is one form of extension, but not necessarily the best way to achieve flexibility in our designs.
In our designs we should allow behavior to be extended w/o the need to modify existing code (open-Closed Principle)
Composition and Delegation can often be used to add new behaviors at runtime.

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

Facade

A

The facade design pattern specifies the creation of a class with a unified interface to a set of interfaces (publicly exposed methods) in a subsystem.
The facade pattern defies a higher-level interface that makes a subsystem easier to use.
By using the Facade pattern, we provide a simple interface to a complex subsystem. This interface is good enough for most clients, more sophisticated clients can look beyond the facade.
We can also decouple the classes of a subsystem from client classes and other subsystem, thereby promoting subsystem independence and

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

Factory Design Pattern

A

defines a technique to encapsulate the details of object creation in a single class known as a “Factory” class whose job it is as to create concrete instances of various objects that implements a given interface.
The other objects in the application that need new objects created by the factory by the factory class are known as “clients” of the factory.

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

Flyweight Design Pattern

A

is used to reduce the memory and resources usage for complex applications containing many hundreds, thousands or millions of duplicate objects.
To do this, the flyweight pattern specifies a solution whein only one object holding a specific value (or specific set of values) is ever created - rather than 2, or 10, 10000 objects each holding the same value.

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

Memento Design Pattern

A

is a design pattern that permits the current state of an object to be “externally” stored w/o breaking the rules of Encapsulation or the SRP principle.
The domain object can be modified as required but can be restored to the saved state at any time.
To support an undo operation, an application must be able to revert to the state in which it existed before a user executed an operation.
There are at least a couple ways you can implement this: Operation Reversal, and State Storage

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

Monostate Design Pattern

A

defines a “conceptual singleton”.
It is not a true singleton because multiple instances of the Monostate class can be created, but all data attributes of a Monostate class are declared as “static” so that all instances of the Monostate class share the same (static) data attributes values.
In this way, you can create one or more thousand instances of a Monostate class and all of those objects will share and see the same values for the Monostate’s data attributes.
Users of a Monostate objects do not behave differently than users of a regular object. The users do not need to know that the object is monostate
Subclasses of a Monostate classes are Monostates. Indeed, all the derivatives of a Monostate are part of the same Monostate. They all share the same static variables
Since the methods of a Monostate are not static, they can be overridden in a derivative. Thus different derivatives can offer different behavior over the same set of static variables.

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

MVC

A

design pattern is a widely used architectural pattern in software engineering, particularly in developing user interfaces.

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

Null Object Design Pattern

A

If an object reference may be optionally “null” and this reference must be checked before every use and the result of a “null” check is to do nothing or assign a suitable default value -
Then we can create which implements the same interface as the other implementations objects, provide implementations for all the requisite methods that do nothing to provide default results and use an instance of this class whenever the object reference would have beeen “null”.

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

Observer Design Pattern

A

allows one object (or more) - the observer - to watch another - the subject.
The Observer pattern allows the subject and observer to form a publish-subscribe relationship.
Throug the Observer pattern, observer can register to receive events from the subject from the subject. When the subject needs to inform its observer of an event, it simply sends the event to each registered observer
inform its observer of an event, it simply sends the event to each registered observer
This pattern is a behavioral design pattern.
The observer pattern is also known as the broadcaster-listener or publisher-subscriber pattern.

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

Power Type Design Pattern

A

patterns specifies a technique for removing the unchanging “type” data from classes representing individual objects and instead creating a new second object that will contain that unchangind “type” data (i.e., the “Power Type”)
The individual objects of a given type (i.e., the individual aircraft in our example) will own a reference to a “power type” object that they can use to access the power type object data values. specifies a technique for removing the unchanging “type” data from classes representing individual objects and instead creating a new second object that will contain that unchanging “type” data (i.e., the “Power Type”)
The Power Type pattern helps to reduce the space needed by a set of objects by removing the need to store duplicate data values.

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

Singleton Design Pattern

A

pattern is designed to restrict instantiation of a class to one object.
This pattern is implemented by creating a class w. A method that creates a new instance of the object only if one does not already exist.
If one does exist, it returns a reference to the object that already exists.
If not, a new instance is created and a reference to that new object is returned.
To make sure that the object cannot be instantitiated any other way the constructor is made either private or protected.

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

Strategy Design Pattern

A

pattern is designed to restrict instantiation of a class to one object.
This pattern is implemented by creating a class w. A method that creates a new instance of the object only if one does not already exist.
If one does exist, it returns a reference to the object that already exists.
If not, a new instance is created and a reference to that new object is returned.
To make sure that the object cannot be instantitiated any other way the constructor is made either private or protected.

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