What are design patterns


What are design patterns ?

✍: Guest


Design patterns are recurring solution to recurring problems in software architecture.
(A) Can you list down all patterns and their classification ?
Note :- This is advanced question because anyone who asks to list down all patterns can only be crazy for what he is asking. But it is always a win-win situation for the interviewer. There are three basic classification of patterns Creational, Structural and Behavioral patterns.
Creational Patterns
ã Abstract Factory:- Creates an instance of several families of classes
ã Builder :- Separates object construction from its representation
ã Factory Method:- Creates an instance of several derived classes
ã Prototype:- A fully initialized instance to be copied or cloned
ã Singleton:- A class in which only a single instance can exist

Note :- The best way to remember Creational pattern is by ABFPS (Abraham Became First President of States).
Structural Patterns
ã Adapter:-Match interfaces of different classes. ã Bridge:-Separates an objectfs interface from its implementation.
ã Composite:-A tree structure of simple and composite objects.
ã Decorator :-Add responsibilities to objects dynamically.
ã Facade:-A single class that represents an entire subsystem.
ã Flyweight:-A fine-grained instance used for efficient sharing.
ã Proxy:-An object representing another object.

Note : To remember structural pattern best is (ABCDFFP)
Behavioral Patterns
ã Mediator:-Defines simplified communication between classes.
ã Memento:-Capture and restore an object's internal state.
ã Interpreter:-A way to include language elements in a program.
ã Iterator:-Sequentially access the elements of a collection.
ã Chain of Resp:-A way of passing a request between a chain of objects.
ã Command:-Encapsulate a command request as an object.
ã State:-Alter an object's behavior when its state changes.
ã Strategy:-Encapsulates an algorithm inside a class.
ã Observer:-A way of notifying change to a number of classes.
ã Template Method:-Defer the exact steps of an algorithm to a subclass.
ã Visitor:-Defines a new operation to a class without change.

Note :- Just remember Music....... 2 MICS On TV (MMIICCSSOTV).
Note:- No source code is provided for architecture section as much of the things can be clear from good UML diagrams.

2007-10-24, 5253👍, 0💬