Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Newbie question about methods
Message
 
To
30/07/1998 13:43:53
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00122766
Message ID:
00122806
Views:
13
>Hi All,
>
>I feel stupid asking this question, but I am just learning VFP. It seems that most methods for custom controls are stored in the class library file. However some samples which I have seen lately seem to handle some methods in a different way. Some of the methods for some specific controls are defined only after the control is placed on a form. This kind of method is apparently not part of the class definition. I am confused.
>
>When you modify a method of a control after it has been placed on a form, where is the code stored? What are the reasons why you would want to use this kind of a method rather than including the method in the class definition? With this approach, it almost seems like the form becomes very much like a class definition.
>
>Please help me understand.
>
>TIA

Sam,

You raise a very interesting and important question. You should not feel embarassed by this question at all.

Writing code in the form designer is what is referred to as instance programming. It get this name because you are modifying behavior in the object instance instead of in the object's class.

In the pure OO approach to programming, one would NEVER program in the instance, all code goes in the class definitions. The only programming done in the instance is setting properties.

This is where the value of hidden methods and properties comes into being. If the method is hidden then no one can alter it in the instance.

Enter the pragmatic programmer in us all. It is often easier to create a class that does most of what we want and then specialize its behavior in each form. When we do this we are , in fact, violating good OO design. The price we pay is in the overall maintenance required. With code floating around in all the forms, we have to make chanes in those forms. If all ciode was in classes, any change we made would affect all forms.

Your observation is right on, in that we should not be programming in the form designer. If we drop a button on a form and it doesn't do what we want, we should fix the class so that it does.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform