>So would you recommend starting with the foundation classes, then subclass as needed? Keep in mind I am just an "advanced beginner" at VFP wanting to learn more, and all I can about programming with it.
It really depends on your needs and the specific class involved.
Keep in mind that the foundation classes form a basic framework themselves. Many of them can be instantiated directly (ie, without subclassing), wherein you use their properties and methods to achieve the customization you want.
At the next level, you can create a first-level subclass. You might do this if you want to add to or override the class behavior, or just to change the default value of some properties. As a most fundamental example, consider the _msgbox (MessageBox Handler). It includes a cTitle property for the window title bar. You may want it to have a default value across your entire application without having to specify that for every call to the class. In this instance, you could do soemthing as simple as:
DEFINE CLASS MyMsgBox AS _msgbox
cTitle = "My Application Message"
ENDDEFINE
Now you just instantiate MyMsgBox all the time and you get the default behavior. (Individual instances can of course override the property if needed.)
A further step is to define an abstract subclass below the Foundation Class from which all your further subclasses derive. This gives you a "layer" between your applications and the framework wherein you can define (later or now) any default behavior that you want to apply to all uses of that class. In this scenario, the abstract layer is derived from the Foundation Class, and your application classes are derived from your own abstract classes.
[Note that while this kind of abstract layer is highly recommended when you work with VFP base classes or most other simple classes, you need to be very careful before deciding to do this with any composite class (eg, Password Dialog box). Drew Speedie wrote a good article a year or so ago about dangers in composite development. I would recommend avoiding subclassing of composites where posssible, or at least asking questions here before doing so.]
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only