Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Which design patterns for my FSM?

Reply
Thread Tools

Which design patterns for my FSM?

 
 
LarryTheSoftwareGuy@hotmail.com
Guest
Posts: n/a
 
      07-18-2007
Folks,

Would love some suggestions re what design patterns to use for this
situation.

I need to create a simple FSM. A certain login scenario will behave
differently based on the following:

· 1 - 3 session traits, which are already established & stay the same
for the session duration. Trait #2 is only relevant if trait #1 is a
certain value. Trait #3 is only relevant if trait #2 is a certain
value.
· 2 different sets of states - plus a third state if the 2nd state has
a certain value.

All these traits & states are maintained locally in my program.

When I look at the possibilities in GoF & in Alexandrescu on how to
implement this, my head spins - Object factory? Abstract factory?
Functor? State pattern? Decorator? Brute force 'if' tests? All of
the above? (More than one of the above I'm sure, but I'd love some
general suggestions on which pattern would make sense where.) Thank
you verrrrry much.

Larry Kay

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      07-19-2007
wrote:
> Would love some suggestions re what design patterns to use for this
> situation.
>
> I need to create a simple FSM. [...]


Have you tried 'comp.software.patterns'?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


 
Reply With Quote
 
 
 
 
Zachary Turner
Guest
Posts: n/a
 
      07-19-2007
On Jul 18, 4:21 pm, LarryTheSoftware...@hotmail.com wrote:
> Folks,
>
> Would love some suggestions re what design patterns to use for this
> situation.
>
> I need to create a simple FSM. A certain login scenario will behave
> differently based on the following:
>
> · 1 - 3 session traits, which are already established & stay the same
> for the session duration. Trait #2 is only relevant if trait #1 is a
> certain value. Trait #3 is only relevant if trait #2 is a certain
> value.
> · 2 different sets of states - plus a third state if the 2nd state has
> a certain value.
>
> All these traits & states are maintained locally in my program.
>
> When I look at the possibilities in GoF & in Alexandrescu on how to
> implement this, my head spins - Object factory? Abstract factory?
> Functor? State pattern? Decorator? Brute force 'if' tests? All of
> the above? (More than one of the above I'm sure, but I'd love some
> general suggestions on which pattern would make sense where.) Thank
> you verrrrry much.
>
> Larry Kay


Sometimes it's best not to force existing design patterns on
yourself. How about a HSM (Heierarchical State Machine). Make a
class representing each "state". These all derive from the same
abstract class, which has methods like Enter(), Leave(), and
Execute(). Each of these states has sub-states.

Then, in each subclass, you can have totally different trait
enumerations since certain traits only apply to certain states. Plus
the 3rd state can exist only as a member of the 2nd state. Etc.
Organizing state machines into heierarchies can be pretty useful in
cases like this where each state itself defines a complex set of
behavior.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Has anybody here read Design Patterns Explained: A New Perspective on Object-Oriented Design John Java 0 06-01-2007 02:45 PM
Design Pattern Relationship Diagram - Design Patterns - Gang of Four Tim Smith C++ 2 12-15-2004 05:22 PM
ebook on Software Design Patterns (C#.NET) Siz ASP .Net 1 12-12-2004 09:32 PM
New open source software to use Design Patterns Josh28 ASP .Net 0 11-29-2004 10:54 AM
where to find good patterns and sources of patterns (was Re: singletons) crichmon C++ 4 07-07-2004 10:02 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57