I have run into a corner-case problem with the general guidance of:
- nouns for variables
- verbs for functions
Specifically, I have a case where the word is ambiguous - it can be either a verb or a noun. And in some cases when we're discussing the application, it will be used both ways in the same sentence.
My intent is to make sure the program will remain readable to future developers as well as myself when I return to sections of code months later.
One of the examples is with a
battery has a
charge and you can also
charge() a battery.
I think that having both
Battery.Charge(value) will be confusing to future developers.
My current solution is to simply pick a different word for one or both of those cases (the variable and the function). My problem with that approach is the
Battery object's variable and function for
charge won't align with design discussions involving the
My question is if there is another / better way to handle this conflict in naming convention?
Some additional reading on the subject. None really addressed the particular of my question.
- http://programmers.stackexchange.com/questions/119345/meaningful-concise-method-naming-guidelinesMeaningful concise method naming guidelines
- http://programmers.stackexchange.com/questions/33532/naming-conventions-for-variablesNaming conventions for variables
- The selected answer from http://programmers.stackexchange.com/questions/14169/what-naming-guidelines-do-you-followhttps://softwareengineering.stackexchange.com/questions/14169/what-naming-guidelines-do-you-follow