5 ms·
What acronyms and abbreviations in source code are sensible?
I'm thinking things along the lines of "num" for "numberOf" and "max" for "maximumOf".
- quickthrower2 7y agoWhatever all the contributors can agree on, keeping in mind there may be future contributors e.g. new starters. So if it’s a solo project anything goes. If it’s going to be maintained by a big team long term then be conservative.
- zzo38computer 7y agoAnything, although if it is unclear then comments can be helpful to clarify it.
- bjourne 7y agoIt depends. For example, if you are writing code using HMMs the following would be adequate: while True: pi1 = dot(A, pi) if norm(pi - pi1) < eps: return pi1 Because whoever is reading the code can be expected to know what pi, pi1, A, dot, eps and norm are from context. I usually write some comments at the top of the module in case things could be unclear. Then I use short names wherever possible; subst for substitute, tmpl for template, expr for expression and so on. But you have to experiment yourself and see what fits your style and programming strength -- there are no hard and fast rules.