Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
To Class or not to class
Message
De
10/04/2018 05:03:18
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
10/04/2018 01:17:23
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01659269
Message ID:
01659279
Vues:
47
>>Also the gymnastics sometimes used by Java and C# to allow running code without the class being instantiated argue for function libraries in my book ;-)))
>
>Edge conditions always but by definition seldom apply. And in most cases the call will be to a method in the class foranything with a large number of calls. As with all programming whether classes or prg libraries, the goal is to segregate functionalities into separate ecologies.
>
>So after taking the above into account, the decision devolves to the major differences between the two approaches, I think along the lines I laid out.

So I enjoy having both of them. The general functions can be divided by datasession sensitivity. If they require passing an alias, then I definitely don't want them in a class, because I'd have to have that instantiated in the current datasession, or do some serious session jumping. Or I'd have such an object instantiated in each datasession by default - but then as the number of such functions grows, this object would be heavier. So it's a matter of style, housekeeping, and the primary question of all OOP: where does the code go?

The coding time being generally more expensive than runtime, my answer is "it goes to wherever you'll easily find it". Now with GoFish4 being this fast, it seems more important to give good names to your functions so you don't get too many false positives when searching - things like this.IsAnIceBreaker and function IsAnIceBreaker() may not hurt syntactically, it'll compile fine, but will make it slower when you goFish for it and have to visually recognize which is which. Yes, you can search for one with the preceding dot and for the other with a trailing parenthesis, but generally you'll forget to do that the first time.

That all being said, I don't quite have a preference. Having worked with several teams over the years, I generally try to be a chameleon and adapt the team's style (except when they are horribly wrong!). When there's a case for putting a group of functions into a specialized object, it's usually too late, these functions already exist and are called from many places, but it's actually easy to just rewrite those functions to be wrappers and call the methods of that object (usually a global singleton).

So I'd guess in the mentioned languages you need to care about which classes are involved in what you're doing; in VFP you need to care about datasessions.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform