Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Design Patterns

Similar presentations


Presentation on theme: "Introduction to Design Patterns"— Presentation transcript:

1 Introduction to Design Patterns
1

2 Pattern?? A pattern is based on the principles of object-oriented programming: abstraction, inheritance, polymorphism and association A pattern is a recurring solution to a standard problem, in a context A pattern is independent of the application domain A pattern is a three-part rule, which expresses a relation between a certain context, a problem, and a solution

3 Design Pattern Advantages
Using patterns offers a few key advantages: Promote reuse Facilitate a proven solution Provide a common vocabulary “Design patterns help a designer get a design right faster”

4 Types of Patterns Creational patterns Structural patterns
Focus on the best way to create instances of objects to promote flexibility Structural patterns Focus on the composition of classes and objects into larger structures Behavioral patterns Focus on the interaction between classes or objects Distribute responsibility

5 Relationships between Patterns
Some patterns are used together, for example the composite pattern is sometimes used with the iterator or visitor Some patterns are also defined as alternatives for others, e.g. the prototype pattern can be used as an alternative to the abstract factory pattern Some patterns, e.g. the composite and decorator pattern, result in similar designs

6 Creational Design Patterns
Abstract Factory Factory for building related objects Builder Separates an object construction from its representation Factory Method Creates an instance of several derived classes Prototype Factory for cloning new instances from a prototype Singleton A class of which a single object can exist

7 Structural Patterns Adapter Bridge Composite Decorator Facade
Match interfaces of different classes Bridge Separates an object’s interface from its implementation Composite A tree structure of simple and composite objects Decorator Add responsibilities of objects dynamically Facade A single class that represents the entire subsystem

8 Structural Patterns (cont.)
Flyweight A fine-grained objects shared efficiently Proxy An object representing another object

9 Behavioral Patterns Chain of Responsibility Command Iterator
Passes a request between a chain of objects Command Encapsulates a command request as an object Iterator Elements of a collection are accessed sequentially Interpreter Language elements are included Mediator Defines simplified communication between classes

10 Behavioral Patterns (cont.)
Memento Capture and restores an object’s internal state Observer A way of notifying change to a number of classes State Alter an object’s behavior when its state changes Strategy Encapsulates an algorithm inside a class Template Method Defer the exact steps of an algorithm to a subclass

11 Behavioral Patterns (cont.)
Visitor Defines a new operation to a class without change

12 Benefits of Design Patterns
Design patterns enable large-scale reuse of software architectures and also help document systems Patterns help improve developer communication Pattern names form a common vocabulary Patterns help ease the transition to Object Oriented technology

13 Drawbacks of Design Patterns
Patterns do not lead to direct code reuse Patterns are deceptively simple Teams may suffer from pattern overload Patterns are validated by experience and discussion rather than by automated testing Integrating patterns is a human-intensive activity

14 Suggestions for Effective Use
Obtain an overview of the pattern Obtain an understanding of the classes and objects and relationships between them Choose application-specific names for the components of the patterns Define the classes Choose application-specific names for the operations defined in the pattern Implement the necessary operations and relationships

15 ?

16 References


Download ppt "Introduction to Design Patterns"

Similar presentations


Ads by Google