1 / 22

Design Patterns

Learn about the definition, history, and benefits of design patterns in software design. Explore different creational, structural, and behavioral patterns. Improve code quality and development efficiency.

bbarron
Download Presentation

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. Design Patterns • Supada Laosooksathit

  2. Content • Definition • History • Benefits • Classification

  3. Definition • Reusable solution to a standard reoccurring problem • Template for a problem that can be used in many different situations • Deal with problems at the level of software design

  4. History • Christopher Alexander • Originated as an architectural concept • Kent Beck and Ward Cunningham • presented the idea of applying patterns to programming at OOPSLA conference (1987) • Gang of Four • Eric Gamma, Richard Helm, Ralph Johnson, John Vlissides • published “Design Patterns: Elements of Reusable Object-Oriented Software”

  5. Benefits • Speeds up the development process • Provides solutions documented in a typical format • Prevents subtle issues that can cause major problems • Improves code readability because of the patterns • Makes communication between designers more efficient

  6. Classification • Creational Patterns • Structural Patterns • Behavioral Patterns

  7. Classification • Creational Patterns • Structural Patterns • Behavioral Patterns

  8. Creational Patterns • Abstract Factory • Provides an interface for creating families of objects • Provides a way to encapsulate a group of individual factories that have a common theme • Factory Method • Defines an interface for creating objects • Lets subclasses decide which class to instantiate

  9. Creational Patterns • Builder • Separate the construction of a complex object from its representation • The same construction process can create different representations • Object Pool • A set of initialized objects that are kept ready to use • Client requests an object, operates and returns to the pool • Effective when the cost of initializing a class instance is high

  10. Creational Patterns • Prototype • Creates a clone of object • Avoid creation a costly new one • Singleton • Restrict instantiation of a class to one object

  11. Classification • Creational Patterns • Structural Patterns • Behavioral Patterns

  12. Structural Patterns • Adapter • Allows classes work together by wrapping an existing class with a new interface • Bridge • Separate the interface from it implementation • Separate responsibilities into different classes • Those classes can vary independently

  13. Structural Patterns • Composite • Allows a group of objects to be composed into tree structures • Represent part-whole hierarchies • Decorator • Attaches new or additional behavior and functionality to an object

  14. Structural Patterns • Facade • Provides a simplified interface to a large body of code • Flyweight • Describes how to share objects to avoid creating a large number of objects • Proxy • Provides a holder for another object to control access to it • Add a wrapper and delegation to protect a real component

  15. Classification • Creational Patterns • Structural Patterns • Behavioral Patterns

  16. Behavioral Patterns • Chain of Responsibility • Chain the receiving objects and pass the request behavior along the chain until an object handles it • Command • Encapsulates a request as an object • Object is used to represent actions

  17. Behavioral Patterns • Interpreter • Defines a grammatical representation for a language • Interpret sentences in the language • Iterator • Provides a common interface for iterating through collections without bothering about underlying implementation

  18. Behavioral Patterns • Mediator • Deals with the complexity of classes increase • Keep objects from referring to each other • Allows objects’ interaction be varied independently • Memento • Provides the ability to restore an object to its previous state

  19. Behavioral Patterns • Observer • When one object changes state, all dependents are notified and updated automatically • State • Allows an object to alter its behavior when its internal state changes

  20. Behavioral Patterns • Strategy • An object and its behavior are separated and put into two different classes • Allows the algorithm changeable anytime • Template Method • Set up the skeleton of an algorithm in an operation

  21. Behavioral Patterns • Visitor • Defines a new operation to be performed on the elements of an object structure • No change of the element classes

  22. Thank you

More Related