I'm looking to see if there is a particular name for this style of programming a certain kind of behavior into a program.
Said program runs in real time, in an update loop, and the program uses the State design pattern to do some work, but it's the specific way it does the work that I want to know about.
Here's how it's used.
- Object Foo constructed, with concrete StateA object in it
- First loop runs
--- Foo.Run function calls StateA.Bar
--- in StateA.Bar replace Foo's state to StateB
- Second loop runs
--- Foo.Run calls StateB.Bar
- Third loop runs
--- Foo.Run calls StateB.Bar
- Fourth loop
--- etc.
So in short, Foo
doesn't have an explicit Initialize
function. It will just have Run
, but Run
will do something unique in the first frame to initialize something for Foo
and then replace it with a different action that will repeat in all the frames following it- thus not needing to check if Foo
's already initialized. It's just a "press start and go" action.
What would you call implementing this type of behavior?
in StateA.Bar replace Foo's state to StateB
. Do you mean that the objectStateA
gets replaced by the objectStateB
? – Robert Harvey Aug 29 '12 at 17:44if Foo.initialized, do action A, else do action B
and needing to check for that every time the loop runs. The way Foo is set up I cannot do action A anywhere but inside the loop. – Chris C Aug 29 '12 at 18:08