The best way to track many properties

I tend to use many global variables (properties) in my projects, but I find that after a while I start to forget the names of those properties. In vb I used the Type declaration to pseudo-class variables. At the moment I create groups of properties in classes and declare them globally, but I am not sure that this is the best practice. I am interested to hear how others track and maintain big lists of properties within a project.

You could use modules as namespaces. Group the properties in modules. Make them protected, not global. Now you can only use them outside of their module by prepending them with the module name. Then you have autocomplete after typing in the module name.

But generally one should avoid global variables (google for “why are global variables bad”). Over the years I’ve learned to avoid them almost entirely (including not so obvious cases like singletons, public shared members on classes, etc.). I now mainly use constructor dependency injection.

In VB you had TYPE, in XOJO you have STRUCTURE (with the limitation that strings must be fixed length)
Otherwise use CLASS

And while I agree to never make ALL your variables global, there are situations where application wide variables or constants are required

Eli, could you expand a bit on how you’re doing this in Xojo. Thx.

It’s always a good idea to declare your variables in the most restrictive scope possible. Globals may seem like a good idea to start with but don’t let them fool you, they’re bad. In general, that is. There is never ever an absolute :slight_smile: