Hw8 GoF state, strategy, tempate method, visitor

241 views
197 views

Published on

GoF Patterns: State, Strategy, Template Method and Visitor

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
241
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Hw8 GoF state, strategy, tempate method, visitor

  1. 1. UTAH STATE UNIVERSITY COMPUTER SCIENCE CS-7350 Reading Assignment GoF Patterns: State, Strategy, Template Method and Visitor Jorge Edison Lascano Spring 2012 01-27-2012STATE, STRATEGY, TEMPLATE METHOD and VISITORGoF PATTERNSState, is it really easy to add new states?It is not easy, since ConcreteState objectsbehavior depends on each other, in this sense, thecomplexity of selecting the subsequent state is sparsed among all objects (the intelligence isdistributed). If we need to model this behavior, a Multi Object State Machine Diagram will beneeded, and it can become a very complex task if more states are needed.Besides,if transitionsare not controlled by some component, certain kind of anarchy may occur. As ConcreteStates aresupposed to work as a team, Observer pattern could be a possible solution that allows notifyingwhen object changed its state or a new object appears, aflag can be used to indicate the activestate in time, it is still not easy to increase states though, but its collaborative behavior is bettercontrolled.In Strategy, the client still has to take the decision on which object to use. Template Method, isdifficult to maintain when ConcreteClasses are increased and worse if levels of hierarchy areadded. Visitor, is a wrapper with special permissions that breaks some encapsulation of thevisitees.

×