|
| State Pattern with Delphi Win32 |
 |
Sun, 06 Apr 2008 13:28:08 -040 |
I was wondering how others have handled the state pattern or if someone can
point me to a delphi centic example of the state pattern.
With dynamic languages like Java and .net it seems pretty straight forward since
there is no need to manually free each state object. But with Delphi win32 (not
using interfaces) I'm wondering how to go about disposing of the existing state
object when a new one is created and takes over.
Thanks for input/advise.
--
Warm Regards,
|
| Post Reply
|
| Re: State Pattern with Delphi Win32 |
 |
Sun, 06 Apr 2008 13:47:38 -040 |
Lee Jenkins wrote:
>
> I was wondering how others have handled the state pattern or if someone
> can point me to a delphi centic example of the state pattern.
>
> With dynamic languages like Java and .net it seems pretty straight
> forward since there is no need to manually free each state object. But
> with Delphi win32 (not using interfaces) I'm wondering how to go about
> disposing of the existing state object when a new one is created and
> takes over.
>
> Thanks for input/advise.
>
Oops. Found an example here:
http://sourcemaking.com/design_patterns/state
--
Warm Regards,
|
| Post Reply
|
| Re: State Pattern with Delphi Win32 |
 |
Sun, 6 Apr 2008 15:24:20 -0400 |
On Sun, 06 Apr 2008 13:28:08 -0400, Lee Jenkins wrote:
> I was wondering how others have handled the state pattern or if someone can
> point me to a delphi centic example of the state pattern.
>
> With dynamic languages like Java and .net it seems pretty straight forward
since
> there is no need to manually free each state object. But with Delphi win32
(not
> using interfaces) I'm wondering how to go about disposing of the existing
state
> object when a new one is created and takes over.
I would either keep a set of states pre-created for the whole
application or for the life of the container object.
The alternative is just to destroy it when a new state is assigned and
make it a rule for other objects not to hold references to the state
object.
--
Marc Rohloff [TeamB]
|
| Post Reply
|
| Re: State Pattern with Delphi Win32 |
 |
Sun, 06 Apr 2008 19:37:33 -040 |
Marc Rohloff [TeamB] wrote:
> On Sun, 06 Apr 2008 13:28:08 -0400, Lee Jenkins wrote:
>
>> I was wondering how others have handled the state pattern or if someone
can
>> point me to a delphi centic example of the state pattern.
>>
>> With dynamic languages like Java and .net it seems pretty straight
forward since
>> there is no need to manually free each state object. But with Delphi
win32 (not
>> using interfaces) I'm wondering how to go about disposing of the
existing state
>> object when a new one is created and takes over.
>
> I would either keep a set of states pre-created for the whole
> application or for the life of the container object.
> The alternative is just to destroy it when a new state is assigned and
> make it a rule for other objects not to hold references to the state
> object.
>
>
Thanks Marc,
That seems to be the best bet from what I've seen so far.
Thanks again,
--
Warm Regards,
|
| Post Reply
|
| Re: State Pattern with Delphi Win32 |
 |
Mon, 07 Apr 2008 12:35:13 -040 |
Marc Rohloff [TeamB] wrote:
> On Sun, 06 Apr 2008 13:28:08 -0400, Lee Jenkins wrote:
>
>> I was wondering how others have handled the state pattern or if someone
can
>> point me to a delphi centic example of the state pattern.
>>
>> With dynamic languages like Java and .net it seems pretty straight
forward since
>> there is no need to manually free each state object. But with Delphi
win32 (not
>> using interfaces) I'm wondering how to go about disposing of the
existing state
>> object when a new one is created and takes over.
>
> I would either keep a set of states pre-created for the whole
> application or for the life of the container object.
> The alternative is just to destroy it when a new state is assigned and
> make it a rule for other objects not to hold references to the state
> object.
>
>
Worked like a champ. Just used State Pattern to write a class to read keyboard
wedge mag stripe readers.
Thanks again,
--
Warm Regards,
|
| Post Reply
|
|
|
|
|
|
|
|
|
|