Where should I define constants in scripts?
Posted
by
bshacklett
on Programmers
See other posts from Programmers
or by bshacklett
Published on 2012-10-26T14:55:57Z
Indexed on
2012/10/26
17:18 UTC
Read the original article
Hit count: 254
coding-style
|scripting
When writing scripts using a modern scripting language, e.g. Powershell or JavaScript, where should I define constants? Should I make all constants global for readability and ease of use, or does it make sense to define constants as close to their scopes as possible (in a function, for instance, if it's not needed elsewhere)? I'm thinking mostly of error messages, error IDs, paths to resources or configuration options.
© Programmers or respective owner