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:33:41
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00671062
Message ID:
00671145
Views:
19
Remembering the name of the class should not be a problem. You're already remembering a few hundred command syntaxes now.
Actually I have only one class for properties with simple settings so I only have to remember one additional thing (the name of the class). The parameters being passes are the syntax of the command I'm setting:
And I have all my SETTINGS AND CLEANUP done in 1 line of code in my method/procedures.
But then I have a problem remembering to cleanup after myself :)
Method/Procedure WhatEver

  loObject = CreateObject('Set_Prop','Talk','OFF/ON')
  .....
EndProc
  Replaces:
Method/Procedure WhatEver
  lcTalk = Set('Talk')
  Set Talk OFF/ON
  .....
  Set Talk &lcTalk
EndProc
Define Class Set_Prop as Custom
  cProperty = ''
  cSetting = ''
  Procedure Init(tcProperty,tcSetting)
    This.cProperty = tcProperty
    This.cSetting = Set(tcSetting)
    Set &tcProperty &tcSetting
  EndProc
  Procedure Destroy()
    Local lcProperty, lcSetting
    lcProperty = This.cProperty
    lcSetting = This.cSetting
    Set &lcProperty &lcSetting
  EndProc
EndDefine
>And then I need to remember the name of this class, how to call it, etc. What if somebody wants the class which sets/restores TALK ON instead of OFF? Create another class, or add two methods to SETTALK class (or one method and pass the parameters), remember methods names, etc... Sure you can do things this way, but for such simple cases, IMHO, it is not worth it. But that's just me... :)
>
>>Hi Nick,
>>The advantage is: you don't have to remember to cleanup. When the procedure/method ends, the variable goes out of scope and the destroy() cleans up for you.
>>
>>>I personally do not see very big advantages in having the class for such cases. Those 3 lines are clear and self-sufficient. You will replace them with two lines. What's the big deal? :)
>>>
>>>>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
>>>>
Bill Morris
Previous
Reply
Map
View

Click here to load this message in the networking platform