Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
So why classes?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00536554
Message ID:
00536674
Vues:
7
>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...
>
>thanks for the newbie help.
>
>matt

Good question! I don't think it's a beginner's question either ... I'm still asking it!

I like OO because: it provides another level of structuring an application beyond structural programming. OO seems more "in your face" about what structuring decisions to make at any given point.

After some practice, I find it easier to write even non-visual functionality in an object:

1. The object is persistent, holds all sorts of information in properties that don't have to be passed by parameters, and thus is easier to test.

2. The combination of data and code makes sense for higher level modelling of objects and relationships. It's easier to understand that procedural code with separate data. And, because you're dealing with properties rather than parameters oftentimes, the procedural code is simpler to write and understand.

3. Even in terms of the code, I find it easier to review and maintain a visual class than a procedure file.

As one of your other respondents noted, the first time you notice the repetitive nature of the code, you look for a way to simplify that.

In a sense, it's really easier to write unstructured, non-object oriented code THE FIRST TIME. But, since 80% of all programming is maintenance, the more structured and well-written the code is created, the easier it is to maintain and enhance down the road.

Jay
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform