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 ...
see the GOF Design Patterns and the Patterns Homepage
structure
design for change
see also
see UML
provide interface for creating family of related or dependent objects without specifying their concrete classes
define interface for creating an object, but let subclass decide which class to instantiate
virtual constructor
ensure a class has only one instance and provide a global point of access
// .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; }
specify kinds of objects to create using a prototypical instance and create by copying this prototype
are concerned with how classes and objects are composed to form larger structures
Pattern | Alias | Remarks |
---|
wrapper
recursive composition
communication
deal with algorithms and the assignment of responsibilities between objects
composition
objectify!
one-to-many dependencies and notification