|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
Design Pattern Categorization
What do you mean by design pattern? The concept of design pattern is adopted from the construction-engineering field where the common issues faced during construction are addressed using some structural designs. Definition: Descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context. Design pattern identifies key aspects of a common design structure, extracts the metadata and names them. Each design pattern focuses on a particular object-oriented design problem issue. Design pattern identifies the participating classes and instances, their roles and collaborations, and distribution of responsibilities.
What are the essential elements of Design Pattern? There are four essential elements of design patterns as follows: 1. Pattern Name is a handle we can use to describe a design problem, its solutions, and its consequences. 2. Problem it-self describes when and which pattern to be used. 3. Solution, it describes the elements that contribute to design, their relationships, responsibilities, and collaborations. 4. Consequences, the end results/output on implementation of design. Consequences decide the pros and cons of a design.
How design pattern solves design problem? • Finding appropriate objects • Determining object granularity • Specifying object interfaces • Specifying object implementations
Design Pattern Categorization:
| Purpose | Creational | Structural | Behavioral | Scope | Class | Factory Method | Adapter(Class) | Interpreter | | | Template Method | Object | Abstract Factory | Adapter(Object) | Chain of Responsibility | Builder | Bridge | Command | Prototype | Composite | Iterator | Singleton | Decorator | Mediator | | Façade | Memento | | Fly weight | Observer | | Proxy | State | | | Strategy | | | Visitor |
What are Frameworks? Framework is set of cooperating classes that makes up reusable design for a specific class of software. Framework can help in building compilers for different programming languages and target machines. Framework is dedicated for specific kind of application development. Hence, framework dictates the architecture of the application. The framework captures the design decisions that are common to its application domain. Frameworks emphasize design reuse over code reuse.
Definition: Framework will define the overall structure, its portioning into classes and objects, the key responsibilities. Framework predefines these design parameters so that the application designer/implementer can concentrate on the specifics of your application.
Difference between Design Pattern and Framework: 1. Design patterns are generic in nature and can be used in any kind of application irrespective of there domain. Were as Frameworks are specific in nature and addresses issues that are faced in domains. 2. Design pattern are smaller architectural elements than frameworks. Hence, a typical framework contains several design patterns, but reverses of it is not possible. 3. Frameworks can be embodying in code, but only examples of patterns can be embodying in code.
How to select a design pattern? Consider how design patterns solve design problems. Scan Intent sections. Study how patterns interrelate. Study patterns of like purpose. Examine a cause of redesign. Consider what should be variable in your design.
How to use a design pattern? 1. Read the pattern once through for an overview. 2. Go back and study the structure, participants and collaborations sections. 3. Look at the sample code section to see a concrete example of the pattern in code. 4. Choose names for pattern participants that are meaningful in the application context. 5. Define the classes. 6. Define application-specific names for operations in the pattern. 7. Implement the operations to carry out the responsibilities and collaborations in the pattern.
|
|
| | |
|
|
|
|
|
|
|