Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Abstract classes useful?
Message
From
04/06/2008 12:29:38
Thomas Ganss (Online)
Main Trend
Frankfurt, Germany
 
 
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01320973
Message ID:
01321646
Views:
14
>>>Hmm, I get the feeling that our hunches of abstract versus concrete are not entirely equal. You may well be right, but I also would like to hear what others have to say about it.
>>
>>Maybe I'm just to fond of my init code...
>
>I think you have learned and thought about the subject a lot more than I have done in the past. Without your input I'd not have had the hunches I now have. But it's my hope that others too show their insights or perception. The outcome may well be used to upgrade NewClass.app.
>
>My current pov is that the choice between creating an 'abstract class' and a 'concrete class' must be redefined to: 'incomplete class' versus 'complete class'. 'Incomplete' implying that the developer is free to directly use it on a form, but still will have to add code to certain methods and set certain properties to valid values. Those methods and properties ideally need to be documented.
>
>In a reply to Thomas you used the word dynamically. Indeed, this concept of an incomplete class can be seen as a case of an abstract class that is dynamically upgraded to a complete class that can then indeed be instantiated to a concrete object.

Consider (just typed here: not tested, but you'll get my drift)
loF = createobject("cFormbase")
* as the parameter is set via .init, is the the class "concrete" ? It should work...
loF.AddObject("oDynButton", "WhatAmI","ButtonClickDelegate")  
loF.Show()
READ events

define class WhatAmI as commandButton
   visible = .t. 
   function init (tcFormClickmethod)
      if ! empty(m.tcFormClickmethod)
         = this.addproperty("cAbstractFormClickmethod", m.tcFormClickmethod)
      endif
      if !this.IamConcrete() 
         return .f.
      else
         return dodefault()
      endif

   function click()
      return this.abstract_click()

   function abstract_click()  && events call methods...
      return eval("thisform." + this.cAbstractFormClickmethod + "()")

   function IamConcrete()
     return Type("this.cAbstractFormClickmethod") = "C" and !empty(this.cAbstractFormClickmethod)

enddefine

define class IamPartiallyAbstract as WhatAmI
   cAbstractFormClickmethod = "" && fails in init
enddefine

define class IamClearlyConcrete as IamPartiallyAbstract
   cAbstractFormClickmethod = "ButtonClickDelegate"
enddefine

define class cFormbase as Form
    function ButtonClickDelegate()
        Wait window "Bye from " + program()
        = this.release()
        return
enddefine
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform