designpatternscard1.pdf

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