Designpatternscard

  • 1,582 views
Uploaded on

 

More in: Technology , Business
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,582
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
234
Comments
0
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. C Abstract Factory S Facade S Proxy Memento Memento -state Caretaker B Observer S Adapter C Factory Method Type: Behavioral C Singleton S Bridge S Flyweight What it is: Without violating encapsulation, capture B State C Builder B Interpreter and externalize an object's internal state so that the object can be restored to this B Strategy B Chain of Responsibility B Iterator Originator state later. -state B Template Method B Command B Mediator +setMemento(in m : Memento) B Visitor S Composite B Memento +createMemento() S Decorator C Prototype «interface» notifies Observer Chain of Responsibility «interface» successor «interface» Subject Observer Handler +attach(in o : Observer) Client Type: Behavioral +update() Type: Behavioral +handleRequest() +detach(in o : Observer) +notify() What it is: What it is: Define a one-to-many dependency between Avoid coupling the sender of a request to objects so that when one object changes its receiver by giving more than one object state, all its dependents are notified and a chance to handle the request. Chain the updated automatically. receiving objects and pass the request ConcreteSubject ConcreteObserver observes along the chain until an object handles it. ConcreteHandler1 ConcreteHandler2 -subjectState -observerState +handleRequest() +handleRequest() +update() Command State Context Client Invoker +request() Type: Behavioral «interface» Type: Behavioral State ConcreteCommand What it is: What it is: +handle() Allow an object to alter its behavior when Encapsulate a request as an object, +execute() its internal state changes. The object will thereby letting you parameterize clients appear to change its class. with different requests, queue or log requests, and support undoable operations. Command Receiver +execute() ConcreteState1 ConcreteState2 +action() +handle() +handle() Strategy Client Interpreter Context Type: Behavioral «interface» Type: Behavioral Strategy «interface» What it is: +execute() AbstractExpression Context What it is: Define a family of algorithms, +interpret() Given a language, define a representation encapsulate each one, and make them for its grammar along with an interpreter interchangeable. Lets the algorithm vary that uses the representation to interpret independently from sentences in the language. clients that use it. ConcreteStrategyA ConcreteStrategyB TerminalExpression NonterminalExpression +execute() +execute() +interpret() : Context +interpret() : Context Client Template Method Iterator AbstractClass +templateMethod() Type: Behavioral Type: Behavioral «interface» «interface» #subMethod() Iterator Aggregate What it is: What it is: +next() Define the skeleton of an algorithm in an +createIterator() Provide a way to access the elements of operation, deferring some steps to subclasses. an aggregate object sequentially without Lets subclasses redefine certain steps exposing its underlying representation. of an algorithm without changing the ConcreteClass algorithm's structure. ConcreteIterator +subMethod() ConcreteAggregate +next() : Context +createIterator() : Context «interface» Visitor informs Mediator Visitor «interface» Client Mediator +visitElementA(in a : ConcreteElementA) Type: Behavioral Colleague Type: Behavioral +visitElementB(in b : ConcreteElementB) What it is: What it is: «interface» Represent an operation to be Define an object that encapsulates how a Element performed on the elements of an ConcreteVisitor set of objects interact. Promotes loose +accept(in v : Visitor) object structure. Lets you define a coupling by keeping objects from referring new operation without changing +visitElementA(in a : ConcreteElementA) to each other explicitly and it lets you vary updates the classes of the elements on +visitElementB(in b : ConcreteElementB) their interactions independently. which it operates. ConcreteMediator ConcreteColleague ConcreteElementA ConcreteElementB +accept(in v : Visitor) +accept(in v : Visitor) Copyright © 2007 Jason S. McDonald Gamma, Erich; Helm, Richard; Johnson, Ralph; Vlissides, John (1995). Design Patterns: Elements of Reusable Object-Oriented Software. Reading, Massachusetts: Addison Wesley Longman, Inc.. http://www.McDonaldLand.info
  • 2. Adapter «interface» Proxy Client Adapter Client Type: Structural +operation() Type: Structural «interface» What it is: Subject What it is: Convert the interface of a class into +request() Provide a surrogate or placeholder for another interface clients expect. Lets another object to control access to it. classes work together that couldn't ConcreteAdapter otherwise because of incompatible Adaptee interfaces. -adaptee +adaptedOperation() represents RealSubject Proxy +operation() +request() +request() Abstraction Client Bridge Abstract Factory +operation() «interface» Type: Structural «interface» Type: Creational AbstractFactory Implementor «interface» +createProductA() What it is: +operationImpl() AbstractProduct What it is: +createProductB() Decouple an abstraction from its Provides an interface for creating implementation so that the two can vary families of related or dependent independently. objects without specifying their concrete class. ConcreteFactory ConcreteImplementorA ConcreteImplementorB ConcreteProduct +createProductA() +operationImpl() +operationImpl() +createProductB() «interface» «interface» Composite Builder Component Director Builder children +operation() +construct() +buildPart() Type: Structural Type: Creational +add(in c : Composite) +remove(in c : Composite) What it is: What it is: +getChild(in i : int) Compose objects into tree structures to Separate the construction of a represent part-whole hierarchies. Lets complex object from its representing clients treat individual objects and so that the same construction compositions of objects uniformly. process can create different ConcreteBuilder Composite representations. +buildPart() Leaf +operation() +getResult() +add(in c : Composite) +operation() +remove(in c : Composite) +getChild(in i : int) «interface» Decorator ConcreteComponent Factory Method Creator Component «interface» +operation() Product +operation() +factoryMethod() Type: Structural Type: Creational +anOperation() What it is: What it is: Decorator Attach additional responsibilities to an Define an interface for creating an +operation() object dynamically. Provide a flexible object, but let subclasses decide which alternative to sub-classing for extending class to instantiate. Lets a class defer functionality. instantiation to subclasses. ConcreteDecorator ConcreteCreator ConcreteProduct -addedState +factoryMethod() +operation() +addedBehavior() Client Facade Prototype Facade Complex system «interface» Type: Structural Type: Creational Prototype +clone() What it is: What it is: Provide a unified interface to a set of Specify the kinds of objects to create interfaces in a subsystem. Defines a high- using a prototypical instance, and level interface that makes the subsystem create new objects by copying this easier to use. prototype. ConcretePrototype1 ConcretePrototype2 +clone() +clone() «interface» FlyweightFactory Flyweight Flyweight Singleton +getFlyweight(in key) +operation(in extrinsicState) Singleton Type: Creational Type: Structural -static uniqueInstance Client What it is: -singletonData What it is: Ensure a class only has one instance and Use sharing to support large numbers of +static instance() provide a global point of access to it. fine grained objects efficiently. +SingletonOperation() ConcreteFlyweight -intrinsicState UnsharedConcreteFlyweight +operation(in extrinsicState) -allState +operation(in extrinsicState) Copyright © 2007 Jason S. McDonald Gamma, Erich; Helm, Richard; Johnson, Ralph; Vlissides, John (1995). Design Patterns: Elements of Reusable Object-Oriented Software. Reading, Massachusetts: Addison Wesley Longman, Inc.. http://www.McDonaldLand.info