Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
So why classes?
Message
From
27/07/2001 15:32:23
Gerry Schmitz
GHS Automation Inc.
Calgary, Alberta, Canada
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00536554
Message ID:
00536637
Views:
8
>This is kind of a beginner (easy?) question. I've been learning VFP this last month at a new job, coming from C++ background. I can see why classes in C++, but why classes in VFP.
>
>Perhaps we just aren't taking advantage of classes at work properly. Right now, I make a form into a class. Well why make a form into a class, when I can just keept he form as a form. Besides Heirarchy order (Having a classlib with classes in it, as an ordering device)...i'm just having a hard time figuring out what the use is...

If you write 2+ "Data Entry" Forms that each operate on a different table, and you have another 2+ Forms that use a Parent and Child table, etc. ... you soon start to notice a "pattern" or that you're duplicating a certain amount of code (eg. Add logic, Delete logic, etc). In the old days, we would "reuse" this code by creating function libraries; now, we put that code in a "class" and use a subclass to "inherit" that code. The Forms you subclass account for the differences: eg. validation rules, the fields on the screen, etc.

You could write a couple of forms first that aren't subclassed just to identify your patterns, but given enough forms, at some point there will be code that seems a likely candidate for a parent class, in order to simplify "common code" maintenance and reuse.
Previous
Reply
Map
View

Click here to load this message in the networking platform