Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Why don't I see cleanup class?
Message
De
21/06/2002 13:54:17
 
 
À
21/06/2002 13:14:24
Joel Leach
Memorial Business Systems, Inc.
Tennessie, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00671062
Message ID:
00671163
Vues:
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.

Hi Joel,
Before you start on the Cleanup Class, check my reply to Nick. Put all your simple settings into 1 class and pass the setting-name as a parameter. Keeps things as simple as possible.
Bill Morris
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform