1 / 11

Chapter 10

Chapter 10. Design Patterns. Motivation for Design Patterns. Most software systems contain certain common aspects that are frequently reinvented for each system Solutions to these common problems may vary in quality from system to system

gino
Download Presentation

Chapter 10

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. Chapter 10 Design Patterns

  2. Motivation for Design Patterns • Most software systems contain certain common aspects that are frequently reinvented for each system • Solutions to these common problems may vary in quality from system to system • Design patterns seeks to communicate these classic solutions in an easy to understand manner

  3. What are Design Patterns? • Design Patterns communicate solutions to common programming problems • The seminal book on design patterns, Design Patterns, Elements of Reusable Object-Oriented Software by Gamma et al, identifies three categories of design patterns • Creational • Structural • Behavioral

  4. Creational Patterns • Abstract factory • Facilitates the creation of related objects without concrete class reference • Builder • If a class supports a number of different data representations, the builder encapsulates the details of the necessary conversions • Factory method • Defers determination of specific class to create to a subclass

  5. More Creational Patterns • Prototype • Embodies information comprising prototypical instances • Singleton • Ensures that the class has at most one instance and that other classes have global access to it

  6. Structural Patterns • Adapter • Translates between interacting objects for which the method signatures are incompatible • Bridge • Creates a more flexible mechanism for multiple implementations of an abstract class than inheritance • Composite • Facilitates a generic hierarchical grouping of objects where the class and number of objects may change • Decorator • Allows dynamic addition of new behavior to objects by acting as an outer wrapper containing the added features

  7. More Structural Patterns • Facade • Provides a front end for a series of classes so that users of these classes only need to know of and use the standard set of methods implemented by the facade • Flyweight • Describes a strategy for using an otherwise prohibitive number of very small-scale objects with minimal overhead • Proxy • A means by which the instantiation of certain classes may be delayed until the proxied object is needed

  8. Behavioral Patterns • Chain of responsibility • A strategy that sets up a series of objects that may respond to a message depending on the context of the request • Command • Allows methods to be encapsulated in objects and invoked by a standard means as determined by the interface of the common class • Interpreter • If a set of problems are conducive to being represented as a simple grammar, a class may be defined for each rule

  9. More Behavioral Patterns • Iterator • Separates the class elements necessary for access and traversal from the aggregating class and encapsulates them in the iterator • Mediator • Helps to avoid highly coupled class definitions by moving explicit object references to an intermediary object • Memento • A means to store the otherwise encapsulated internal state of an object for the purpose of creating a check-point or undoing transactions

  10. More Behavioral Patterns • Observer • Allows multiple dependent instances of a class to be notified of relevant changes to the observed class • State • A class hierarchy is defined around a set of states for an object, allowing the behavior of an object to vary depending on a state by substituting the state-specific subclass in its composition • Strategy • Selects a set of related algorithms and encapsulates them in such a way that they may be interchangeable for solving certain problems

  11. More Behavioral Patterns • Template method • Structures a method in such a way that elements of the algorithm are deferred to subclasses • Visitor • Allows the introduction of new operations on the objects that comprise the visited object

More Related