Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Advantage and disadvantage of funct PRG
Message
From
04/12/2017 11:20:44
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
04/12/2017 07:18:30
Mike Yearwood
Toronto, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01656009
Message ID:
01656103
Views:
79
>>So instead of having getAppRootPath.prg, getAppLaunchPath.prg, getUserDocsPath.prg, getTempPath.prg, etc, there is just libPaths.prg, etc etc. The remainder are the few dozen functions which didn't have a natural global object which would host them.
>
>We're not supposed to have god or global objects.

I don't suppose so.

A good example of objects which actually demand one global singleton instance is the settings or config - if its properties may change during the run of the app, then different instances would have different properties, depending on order of instantiation. Another one would be current user's permissions, which would be also consulted many times in various places but instantiated only once, at login.

>I think you meant a natural object to host them. I do make things methods when appropriate. Bear in mind the performance hit added by making these fundamental functions into objects.

Prg-based objects with nothing in .init() (or something minimal) cost almost no time - and that time is once per app launch. Negligible. Time to call, of course it would be a bit longer than plain function. Or maybe not - perhaps there's some whitepaper out there describing the algorithm to search for a name, which actually changed with versions of Fox, so the fastest thing to do was not the same each time. Now it's a question of whether it's faster to find one object among twenty, then one of its methods among a dozen, or to find one function in a list of four hundred.

Usually the cumulative time saved or lost that or other way is, by unknown orders of magnitude, less than the time we spend discussing it :).

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform