Thursday, November 17, 2011

OODesign - Design Pattern 4 (Behavioral pattern)

Ref: http://www.oodesign.com/design-principles.html

Chain of Responsibility
> It avoids attaching the sender of a request to its receiver, giving this way other objects the possibility of handling the request too.
> The objects become parts of a chain and the request is sent from one object to another across the chain until one of the objects will handle it.


Command Pattern
> encapsulate a request in an object
> allows the parameterization of clients with different requests
> allows saving the requests in a queue
(example: Cairngorm Command)

Interpreter
> Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.
> Map a domain to a language, the language to a grammar, and the grammar to a hierarchical object-oriented design
(rarely use)


Iterator
> Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.
var arr:Array = [1, 2, 3];
var it:Iterator = new ArrayIterator( arr );
while ( it.hasNext() ) {
trace( it.next() ); // 1, 2, 3
}

No comments:

Post a Comment