Coding Practice: Naming and best practices for 'overhead' variables
Afficher commentaires plus anciens
Hello all, I have a couple of questions regarding what I will refer to as 'overhead' variables. Examples of these would be variables controlling/identifying: the version of Matlab, whether to use a GPU because a CUDA enabled one is available, the location of a diary/log file, the current evaluation time for different parts of the script, etc.
These variables do not store data, but may be used in different ways by subfunctions during the execution of a code, and need not be retained after code execution. So:
- What is the proper name for these types of variables? Is there one? They are really controlling parameters for the execution of a set of functions, but thats a clunky name.
- Is there a best practice for handing these to a bunch of sub-functions. I am currently using a structure, and a bunch of input parsers, but this requires a fair amount of rewriting any time I modify or add a new overhead variable. I know that global variables are a thing, but avoid them like the plague. Is there a better/cleaner way of handling these in Matlab?
Cheers, Dan
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!