Skip to Content.
Sympa Menu

gang-of-4-patterns - RE: [gang-of-4-patterns] Pattern question: state vs. strategy

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

Subject: Design Patterns discussion

List archive

RE: [gang-of-4-patterns] Pattern question: state vs. strategy


Chronological Thread 
  • From: Jesús Alonso <kenchoweb AT hotmail.com>
  • To: jdeena AT comcast.net, jfreeman AT midwaygames.com, gang-of-4-patterns AT cs.uiuc.edu
  • Cc:
  • Subject: RE: [gang-of-4-patterns] Pattern question: state vs. strategy
  • Date: Wed, 06 Jul 2005 23:38:00 +0200
  • List-archive: <http://mail.cs.uiuc.edu/pipermail/gang-of-4-patterns>
  • List-id: Design Patterns discussion <gang-of-4-patterns.cs.uiuc.edu>

I can't think in which manner Builder and Template Method patterns can be related to each other. The Builder gives a solution to a build-by-parts problem, while the Template Method is useful when you want to define a concrete algorithm skeleton, with slight differences in some steps of the algorithm. Maybe you wanted to say Factory Method? If so, then it just gives a solution to a problem when a class is responsible of creating many different objects depending on a certain discriminator.

Hope that helps.

I like your differentiation between State and Strategy.
I do also have a confusion that I tend to think Builder and TemplateMethod patterns mean the same though they fall in creational and behavioral pattern respectively.
Both encapsulate a process of doing/creating.
Deena

-------------- Original message --------------

> >I'm wondering if you can give me some additional details as to how these
> >are different? Their applicability, purpose and structure seem nearly
> >identical: make the behavior of the context class change dynamically as
> >the state/strategy changes. Both patterns even mentions how they can be
> >tied into the flyweight pattern. The only difference I can readily see
> >is that the state pattern mentions transitions while the strategy does
> >not. Am I missing something?
> >
> >
> >
> >Thank you for your time,
> >
> >-James
>
> I'm not sure, as I haven't used Strategy pattern with the exception of
> academic purposes. Anyways, the difference I see between them is that the
> State pattern acts as a finite state machine, so the transitions between
> them are inside of them, hiding that responsibility away from the client,
> while the Strategy pattern requires the client to transition between
> strategies.
>
>
> _______________________________________________
> gang-of-4-patterns mailing list
>
gang-of-4-patterns AT cs.uiuc.edu
> http://mail.cs.uiuc.edu/mailman/listinfo/gang-of-4-patterns






Archive powered by MHonArc 2.6.16.

Top of Page