Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why don't I see cleanup class?
Message
From
21/06/2002 13:14:24
Joel Leach
Memorial Business Systems, Inc.
Tennessee, United States
 
 
To
21/06/2002 11:58:42
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00671062
Message ID:
00671120
Views:
15
>Every time I see code written by someone else I always see things like:
>
>Procedure ??
>  lcTalk = Set('Talk')
>  Set Talk Off
>  .........
>  Set Talk &lcTalk
>EndProc
>
>Is there a reason people don't use a class to save & restore settings
>
>Procedure ??
>  loTalk = CreateObject('Save_Talk')
>  .....
>EndProc    && Local variables go out of scope forcing destroy()
>Define Class Save_Talk as Custom
>  cTalk = Set('Talk')
>  Procedure Init()
>    Set Talk off
>  EndProc
>  Procedure Destroy()
>    Set Talk This.&cTalk
>  EndProc
>EndDefine
>
How about: Because I never thought about it? I really like it though. In effect, you are localizing global settings, and that is a good thing IMO. I also think that this might qualify as a good example of the "State" design pattern. I usually prefer the OOP way of doing things, so I'll probably use this technique in the future, especially for restoring global settings and work areas. Thanks for sharing.
Joel Leach
Microsoft Certified Professional
Blog: http://www.joelleach.net
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform