1 / 16

Introduction to Design Patterns

Introduction to Design Patterns. 1. 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

matthewneal
Download Presentation

Introduction to Design Patterns

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Design Patterns 1

  2. A pattern is based on the principles of object-oriented programming: abstraction, inheritance, polymorphism and association • A pattern is a recurringsolutionto 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 Pattern??

  3. 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” Design Pattern Advantages

  4. Creational 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 Types of Patterns

  5. 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 Relationships between Patterns

  6. 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 Creational Design Patterns

  7. Adapter • 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 Structural Patterns

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

  9. Chain of Responsibility • 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 Behavioral Patterns

  10. 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 Behavioral Patterns (cont.)

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

  12. 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 Benefits of Design Patterns

  13. 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 Drawbacks of Design Patterns

  14. 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 Suggestions for Effective Use

  15. ?

  16. References

More Related