1.
Purpose. Composite design pattern // 1. Create a "lowest common ...
Delegation and polymorphism } } class Row extends Composite { // Two different kinds of "con- public Row( int val ) { super( val ); } // tainer" classes. ...
2.
Purpose. Need to refactor to sort out "interface vs implementation ...
isEmpty()) push( temp.pop() ); return ret; } } class StackHanoi extends StackArray ... stack2.push( i ); stacks[1].push( i ); } java.util.Random rn = new java.util. ... public Stack() { this( "array" ); } public void push( int in ...
3.
Design Class Diagrams
Design Class Diagrams. Strategy. "Strategy, State, Bridge (and to some degree Adapter) have similar solution structures. They all share elements of the ...
4.
Purpose. Composite // Strategy. Use recursive composition // to ...
... coupled to abstract base class) File( char* n ) { type_ = FileT; strcpy( name_, .... Most of the void traverse() { // "meat" is in the Composite cout ...
5.
Purpose. Prototype #include <iostream.h> // creation via ...
If we design an "extra public: // level of indirection" (a "factory") static .... Larry: poke eyes // Moe: slap head // Curly: suffer abuse // Larry: poke ...
6.
Prototype
... Curly(3) Go(0): 0 // Moe: slap head // Larry: poke eyes // Curly: suffer abuse ... Often, designs start out using Factory Method (less complicated, ...
7.
Visitor
... and the "right thing" can // be done based on the type of both objects. class Color { public: virtual void count() = 0; virtual void call() = 0; ...
8.
Huston Design Patterns
Dozens of 1-page examples in C++ and Java. Before-and-After refactoring examples. ... Design Patterns study group of NYC · Cetus patterns mega home page ...
9.
Huston Design Patterns
UIUC Patterns home page · Patterns FAQ page · Brad Appleton's Web page · Design Patterns study group of NYC · Cetus patterns mega home page ...
10.
Purpose. State #include <iostream.h> // // Discussion. The boss's ...
n"; toggle(b); } } void direct( Boss* b ) { void decide() { cout << "My whim - you're"; .... FSM* fsm ) { total += in; cout << "total is " << total << '\n'; ...