Index  | Recent Threads  | List Attachments  | Search
 Welcome Guest  |  Register  |  Login
Login Name  Password
 

Sweet Home 3D Forum



No member browsing this thread
Thread Status: Active
Total posts in this thread: 5
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 3275 times and has 4 replies Next Thread
Cardinal
Member




Joined: Jul 4, 2011
Post Count: 22
Status: Offline
Reply to this Post  Reply with Quote 
A quick question about ControllerState subclasses

Hello,

Why do some subclasses of ControllerState override setState? Isn't it the same everywhere? (escape() then assign a state)? I don't get it.

Thanks for any help smile
[Jul 26, 2011, 8:22:54 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Puybaret
Expert
Member's Avatar

France
Joined: Nov 7, 2005
Post Count: 9426
Status: Offline
Reply to this Post  Reply with Quote 
Re: A quick question about ControllerState subclasses

setState in PlanController class isn't overridden. It's only used in ControllerState when the state needs to be changed. See State design pattern and UML state machine diagram.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator
[Jul 26, 2011, 9:52:03 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Cardinal
Member




Joined: Jul 4, 2011
Post Count: 22
Status: Offline
Reply to this Post  Reply with Quote 
Re: A quick question about ControllerState subclasses

Sorry I meant setMode() not setState().
[Jul 27, 2011, 8:06:32 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Cardinal
Member




Joined: Jul 4, 2011
Post Count: 22
Status: Offline
Reply to this Post  Reply with Quote 
Re: A quick question about ControllerState subclasses

Is it because you want to prevent self-transitions in some states in order to avoid exit() and enter() from running while the state did not actually change?

On a side note, setMode() in the ControllerState hierarchy is a bit confusing. The argument of the method (mode) is not being retained by the invoker, rather, an assignment is happening at the outer Class level. Thus, It's semantically incorrect to give this method a Setter naming style. A better name would have been switchMode or something to that effect. Correct me if I'm wrong.
[Jul 27, 2011, 9:51:48 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Puybaret
Expert
Member's Avatar

France
Joined: Nov 7, 2005
Post Count: 9426
Status: Offline
Reply to this Post  Reply with Quote 
Re: A quick question about ControllerState subclasses

I guess I wanted to let a state controls what should be done when the user changes current mode.

On a side note, setMode() in the ControllerState hierarchy is a bit confusing. [...]
You're probably right, but I don't believe a lot of programmers are aware of the reason you mentioned... wink
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator
[Aug 7, 2011, 12:49:54 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread

  Get Sweet Home 3D at SourceForge.net. Fast, secure and Free Open Source software downloads  
© Copyright 2024 Space Mushrooms - All rights reserved