Jump to content
C4 Forums | Control4

Variable Naming Schemes


chambrick

Recommended Posts

When naming variables I (being from the Microsoft programming world) adopted the title case pattern. Multiple words are connected without spaces and the first letter is capitolized. (i.e. FireplaceTimer, SprinklerOnOff, etc.)

What do others like?

Link to comment
Share on other sites


I grew up on C programming were common syntax dictated all lowercase with underscore seperations. So far it seems a little easier for me to distinguish between these variables when reading my scripts because they stand out amoungst the proper English sentences.

One thing I always do with boolean variables is give it a true condition name in past tense. For example, you said SprinklerOnOff. I would always name it "sprinkler_on". Therefore if true, then the sprinkler is on. If false, then I know the sprinkler is off. Another example is "all_lights_on" or "special_condition_reached". When you give a variable a name like SprinklerOnOff it causes me to stop reading code and actually take a moment to think about what true and false will represent in this case. It may seem trivial in this example, but other situations are likely to occur to make this a valuable naming convention.

This is the only one that springs to mind ATM.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...