topical media & game development

talk show tell print

pattern(s) / matrix / model(s) / resource(s)

pattern(s) / matrix / model(s) / resource(s)

methods do not provide the intuiton and the direct access to solutions that work in real life. design patterns are the jewels, the cristals of object oriented design ...

pattern(s) / matrix / model(s) / resource(s)

motivation(s)

take for example a document processing system ...

managing composites

problem -- very many items

solution -- flyweight class

managing layout and formatting

problem -- many algorithms

solution -- composer (strategy) class

display item with attributes

problem -- non-uniform attributes

solution -- embed and hide attributes

develop multi-platform tools (1)

problem -- different window toolkits

solution -- employ platform-specific factories

develop multi-platform tools (2)

problem -- offer uniform widget hierarchy

solution -- separate interface from implementation

provide rich functionality

problem -- support commands with undo

solution -- abstract from specific commands

pattern(s) / matrix / model(s) / resource(s)

design patterns

design pattern(s) -- catalogue

see the GOF Design Patterns and the Patterns Homepage

the pattern schema

structure

name - handle

problem - when to apply

solution - general arrangement

consequences - tradeoffs

causes for redesign

design for change

  1. creating an object by specifying a class explicitly -- Abstract Factory, Factory Method, Prototype
  2. dependence on specific operations Chain of Responsibilty, Command
  3. dependence on hardware & software platforms -- Abstract Factory, bridge
  4. dependence on object implementation or representation Abstract Factory, Bridge, Memento, Proxy
  5. algorithm dependence -- Builder, Iterator, Strategy, Template Method, Visitor
  6. extending functionality by subclassing -- Bridge, Chain, Composite, Decorator, Observer
  7. tight coupling -- Abstract Factpry, Bridge, Chain of Responsibilities, Command, Facade, Mediator, Observer
  8. inability to alter classes conveniently -- Adaptor, Decorator, Visitor

kinds of patterns

see also

see UML

pattern(s) / matrix / model(s) / resource(s)

design patterns

design patterns


pattern(s) / matrix / model(s) / resource(s)

creational patterns

factory

provide interface for creating family of related or dependent objects without specifying their concrete classes

Example

also known as kit

participants

consequences

implementation

See GOF

factory method

define interface for creating an object, but let subclass decide which class to instantiate

also know as

virtual constructor

motivation

applicability

structure

participants

consequences

related

singleton

ensure a class has only one instance and provide a global point of access

applicability

implementation

     // .h file 
  
     class Singleton {
     public:
  	static Singleton instance();
     protected: 
limit access
Singleton(); private: static Singleton* _instance; }; // .c file Singleton* Singleton::_instance = 0; Singleton* Singleton::instance() { if (_instance == 0) _instance = new Singleton(); return _instance; }

consequences

etcetera

see GOF

prototype

specify kinds of objects to create using a prototypical instance and create by copying this prototype

motivation

applicability

participants

consequences

related

pattern(s) / matrix / model(s) / resource(s)

structural patterns

structural patterns

are concerned with how classes and objects are composed to form larger structures
PatternAliasRemarks

language mechanisms

adaptor vs bridge

wrapper

Composite vs Decorator vs Proxy

recursive composition

pattern(s) / matrix / model(s) / resource(s)

behavioral patterns

behavioral patterns

communication

deal with algorithms and the assignment of responsibilities between objects

class

object

composition

encapsulating behavior

objectify!

observer

one-to-many dependencies and notification

structure

consequences

implementation


[] readme course(s) preface I 1 2 II 3 4 III 5 6 7 IV 8 9 10 V 11 12 afterthought(s) appendix reference(s) example(s) resource(s) _

(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.