Here are some conventions that I use while writing code, so that anyone reading my code knows what's going on.
- I use snake case, as it's been proven to be faster to read: https://www.cs.kent.edu/~jmaletic/papers/ICPC2010-CamelCaseUnderScoreClouds.pdf, and I like it more
- In general I name my variables in noun_adjective form eg)
max_value
- I don't use hungarian notation, which is the practice of embedding type, purpose, or usage instead I just describe what it does
blah_count
is a varaible that only ever gets incremented by 1, whenever blah occursblah_sum
curr_thing
is a variable that changes over time, it is often used in a context of a for loop where this variable stores a some data which is used iteratively until we are done.- I make my variable almost completely describe what they do when the code is complex, in those cases if the variable name gets too long then I start creating short forms
-
less_than_or_equal_to_list
may becomeltoetl
whenever a shortening occurs, there will be a comment above it with its full name, so if you see something you don't understand check that out. blah_idx
is a index into somethingavg
is an average of something