- Joined
- Jun 26, 2017
- Messages
- 886
I am working on the docs to make them more beginner friendly. At the moment I try to rewrite/modify some basic examples and I wonder what style concerning naming of variables, functions, classes, objects is the best. I try to write them as consistent as possible, so this decision is pretty important at this point.
Style 1: MySomething
myVariable, myFunction, myClassObject
someVariable, SomeClass, someClassInstance
Pros: It is clear, wich kind an identifier describes. No confusion about that.
Cons: Variables should have the purpose in its name. A lot of potential confusion because everything looks like keywords.
Style 2 : Nontechnical context
Variables: age, price; Classes: SuperHero, Frog; Functions: FightEnemy, GoSwimming
Pros: Pretty good destinction between keywords and custom identifiers. Nice Stories can be told. Freedom of naming is obvious.
Cons: Kind of Identifier needs some guesswork. Storytelling talent needed.
Style 3: Mixture of kind and purpose
Variables: varPower; Classes: ClassVehicle, Method: MethOpenDoor
Variants Variables: v_Age, Functions: F_ClearPlanet
Pros: Best of both worlds ;-)
Cons: Can look awkward. Might get verbose. Could be confused with fixed naming rules like text$
Another way could be to give an example with style 1 to emphasize syntax and structure, followed by a near real world example to show purpose and proper naming.
Thoughts and ideas are welcome!
Style 1: MySomething
myVariable, myFunction, myClassObject
someVariable, SomeClass, someClassInstance
Pros: It is clear, wich kind an identifier describes. No confusion about that.
Cons: Variables should have the purpose in its name. A lot of potential confusion because everything looks like keywords.
Style 2 : Nontechnical context
Variables: age, price; Classes: SuperHero, Frog; Functions: FightEnemy, GoSwimming
Pros: Pretty good destinction between keywords and custom identifiers. Nice Stories can be told. Freedom of naming is obvious.
Cons: Kind of Identifier needs some guesswork. Storytelling talent needed.
Style 3: Mixture of kind and purpose
Variables: varPower; Classes: ClassVehicle, Method: MethOpenDoor
Variants Variables: v_Age, Functions: F_ClearPlanet
Pros: Best of both worlds ;-)
Cons: Can look awkward. Might get verbose. Could be confused with fixed naming rules like text$
Another way could be to give an example with style 1 to emphasize syntax and structure, followed by a near real world example to show purpose and proper naming.
Thoughts and ideas are welcome!