textBoxEmployeeName vs employeeNameTextBox

后端 未结 16 970
死守一世寂寞
死守一世寂寞 2020-12-16 00:11

Which naming convention do you use and why?

I like to use employeeNameTextBox, because:

  • It seems more natural from an English language perspective.
16条回答
  •  温柔的废话
    2020-12-16 01:08

    Ideas:

    1. Avoid encodings/abbreviations.

    2. The name should stand out from similar names in the same scope. Make the unique-most part the left-most part. I suspect you have several text boxes, but only one is the employee name.

    3. Avoid needless context. Are all the names on this page about employees? Is it an "employee" page? Then EmployeeName is redundant. NameBox or NameControl should be plenty.

    4. Avoid needless context: do you have names that are not controls? If so, "Box", or "Control" is useful, otherwise not so much.

    Disclosure: I am the "ottinger" from "ottingers naming rules", which also evolved to be chapter 2 of "Clean Code". See short form at http://agileinaflash.blogspot.com/2009/02/meaningful-names.html

提交回复
热议问题