Design Patterns
Design Patterns
DESIGN PATTERNS
• A design pattern is a general reusable solution to a commonly
occurring problem in software design.
• It solves the problem: Design patterns are not just abstract representations of
theoretical research. To be accepted as a pattern it should have some proves practical
experiences.
• It’s a proven concept: Patterns must have a successful history.
• It describes a relationship: Patterns do not specify a single class instead it specifies
more than one classes and their relationship.
• It has a human component : Good patterns make the job of the programmer easy and
time saving.
Contents of Design Pattern
• Name of the pattern is used to identify the pattern as well as a descriptive of the problem solution in
general. Easy to remember and context related names makes remembering patterns easy.
• Context of the pattern describes when and where the pattern is applicable. It also describes the purpose of
pattern and also the place where it is not applicable due to some specific conditions.
• Solution of the design pattern is describes how to build the appropriate design using this appropriate design.
• Consequences of design patterns describe the impact of choosing a particular design pattern in a system.
Criteria for using a design pattern:
1. Pattern Name (good and relevant names make patterns easy to remember)
2. Intent (Which problem does the pattern solve)
3. Also Known As (alias names given to the pattern)
4. Motivation (forces): a scenario consisting of a problem and a context in which
this pattern can be used.
5. Applicability(when should this pattern be applied)
6. Structure(Graphical representation of the Pattern (using UML))
7. Participants(classes and objects taking part in the pattern and their relationship)
8. Collaborators (says how objects/actors interact to achieve the goal).
9. Consequences (how does they solve the problem and what are the consequences if the
problem is solved by this way.)
10. Implementation (Issues related with Implementation, language specific issues)
11. Sample Code: An illustration of how the pattern can be used in a programming language.
12. Known Uses (Examples of the same pattern used in real systems)
13. Related Patterns (Specify is there any similar patterns. Where are they used?)
CREATIONAL PATTERNS
The first type of design pattern is the creational pattern. Creational patterns provide
ways to instantiate single objects or groups of related objects.
STRUCTURAL PATTERNS