Skip to Content.
Sympa Menu

gang-of-4-patterns - State and strategy [was RE : [gang-of-4-patterns] Strategy Pattern vs. Bridge Pattern]

gang-of-4-patterns AT lists.siebelschool.illinois.edu

Subject: Design Patterns discussion

List archive

State and strategy [was RE : [gang-of-4-patterns] Strategy Pattern vs. Bridge Pattern]


Chronological Thread 
  • From: Peter Horan <peter AT deakin.edu.au>
  • To: cfinlayson AT vls-inc.com
  • Cc: gang-of-4-patterns AT cs.uiuc.edu
  • Subject: State and strategy [was RE : [gang-of-4-patterns] Strategy Pattern vs. Bridge Pattern]
  • Date: Fri, 07 Nov 2003 10:53:14 +1100
  • List-archive: <http://mail.cs.uiuc.edu/pipermail/gang-of-4-patterns/>
  • List-id: Design Patterns discussion <gang-of-4-patterns.cs.uiuc.edu>

Chris Finlayson wrote:

To me, a more confusing example is State versus Strategy. I finally
decided that if I would implement it with a set of inner class, then it
was an example of the State pattern. Otherwise, it was a likely
candidate for the Strategy pattern. By that distintion, obviously, only
the one outer class can use the State inner-classes, while the Strategy
pattern can be shared between different classes."

These patterns have the same class and object structure.

The difference is that in strategy, the selected strategy is usually set from outside, and is unlikely to change, whereas in the state pattern, the selected state object changes frequently as defined by the state model in response to the current state and received events.
--
Peter Horan School of Information Technology
peter AT deakin.edu.au
Deakin University
+61-3-5227 1234 (Voice) Geelong, Victoria 3217, AUSTRALIA
+61-3-5227 2028 (FAX) http://www.cm.deakin.edu.au/~peter

-- The Eiffel guarantee: From specification to implementation
-- (http://www.cetus-links.org/oo_eiffel.html)





Archive powered by MHonArc 2.6.16.

Top of Page