How do you go about choosing variable names?
To me this seems to be the atom of abstraction.
So there should be a lot to talk about if we can overcome the scale.
Was recently reading some about DDD [^1] the basic idea being as follows:
- Use ubiquitous language: the language used in the business domain, in coordination with experts
- Divide the language into contexts which assign a unique meaning to each word.
Typically this means division into microservices or separate programs, but it might work okay with modular monoliths.
At a more basic level there is the division of variable names grammatically. [^2]
- transitive verb with direct object: function
- linking verb with predicative adjective: predicate
- transitive verb: method
- singular noun-phrase: non-boolean datum
- predicative adjective: boolean datum
- plural: when multiple entities
- abbreviation: when scope is small
The idea with both of these is to reuse existing language processing for programming.
Anyone have any refinements?
:[^1]
https://www.thoughtworks.com/insights/blog/domain-driven-design-neednt-be-hard-heres-how-start;[^2]
https://dev.to/somedood/a-grammar-based-naming-convention-13jf