Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
To Class or not to class
Message
From
14/04/2018 10:53:14
 
 
To
09/04/2018 17:07:04
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01659269
Message ID:
01659417
Views:
87
Hi Sandy.

>As c# developers know, we can't write a method/procedure/function in c# outside of a class.
>But in VFP you can.

Think of a VFP function or procedure as a static method of a class in that you can call it without having to instantiate the class. Sometimes it makes sense to make a method static, other times to require instantiating the class so you get persistent state (that is, the properties of the class).

One big benefit of VFP functions is that they can be called from expressions, such as in reports. e.g. MyFunction(SomeParameter). Class methods can't be called that way unless the class has been instantiated into an object that's visible to the expression evaluation e.g. SomeObject.MyFunction(SomeParameter). That means the report (or whatever has the expression) is more tightly coupled to the calling code, which is never a good thing.

Doug
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform