1 / 13

Idioms and Patterns

Idioms and Patterns. polymorphism -- inheritance and delegation idioms -- realizing concrete types patterns -- a catalogue of design patterns events -- the reactor pattern . Additional keywords and phrases: generic types, assertions, canonical classes, event-driven computation.

garran
Download Presentation

Idioms and 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. Idioms and Patterns • polymorphism -- inheritance and delegation • idioms -- realizing concrete types • patterns -- a catalogue of design patterns • events -- the reactor pattern Additional keywords and phrases: generic types, assertions, canonical classes, event-driven computation

  2. A catalogue of design patterns Subsections: Creational Patterns Structural Patterns Behavioral Patterns

  3. A Catalogue of Design Patterns • a common design vocabulary • documentation and learning aid • an adjunct to existing methods • a target for redesign

  4. The Pattern Schema Name - handle increases design vocabulary Problem - when to apply explains the problem and the conflict Solution - general arrangement design, responsibilities, collaborations Consequences - tradeoffs to understand the costs and benefits

  5. design for change Causes for Redesign • creating an object by specifying a class explicitly -- Abstract Factory, Factory Method, Prototype • dependence on specific operations -- Chain of Responsibilty, Command • dependence on hardware & software platforms -- Abstract Factory, Bridge • dependence on object implementation or representation --Abstract Factory, Bridge, Memento, Proxy

  6. algorithm dependence -- Iterator, Strategy, Template Method, Visitor • extending functionality by subclassing -- Bridge, Composite, Decorator, Observer • tight coupling -- Abstract Factory, Bridge, Chain of Responsibilities, Command, Facade, Mediator, Observer • inability to alter classes conveniently -- Adaptor, Decorator,

  7. Creational Patterns

  8. Creational Patterns • Factory -- hide concrete classes • Factory Method -- virtual constructors • Prototype -- dynamic creation by cloning • Singleton -- one instance only

  9. Structural Patterns object and class composition Pattern Alias Remarks Composite part/whole collections of components Flyweight part/whole* extrinsic state, many objects Adaptor wrapper resolves inconsistencies Bridge handle/body abstraction to implementation Decorator wrapper to introduce functionality Facade wrapper* provides unified interface Proxy surrogate to defer ... remote, virtual, protection

  10. Behavioral Patterns cooperation algorithms and the assignment of responsibilities between objects class Template Method -- the skeleton of an algorithm Interpreter -- to evaluate expressions object composition Mediator -- provides indirection Chain of Responsibility -- connect objects to interact Observer -- to handle dependencies

  11. Encapsulating behavior objectify! • Command -- action + undo • Strategy -- choice of algorithms • Visitor -- decouple traversal and operations • Iterator -- access and traversal • State -- object state -> behavioral change

  12. The Observer Pattern Observer one-to-many dependencies and notification Consequences abstract coupling between subject and observer constraint propagation deals with unexpected updates

More Related