Smells and Heuristics: Names

N1: Choose Descriptive Names - Dont be too quick to choose a name. Make sure the name is descriptive. Names are what makes 90% of the code readable.

N2: Choose Names At The Appropriate Level Of Abstraction - Don’t pick names that communicate implementation; choose names that reflect the level of abstraction of the class or function you were working in?

N3: Use Standard Nomenclature When Possible - Follow existing conventions in the code when used. For instance, calling all controllers the {something}Controller keeps names consistent.. Each project has it’s own conventions for naming - these are known as the ubiquitous language of the project.

N4: Unabmiguous Names - Choose names that make the workings of the function or variable unambiguous.

N5: Use Long Names For Long Scopes - The length of the name should be related to the scope. Tiny variables can have short names but wider scoped members should have longer names.

N6: Avoid Encodings - Names should not be encoded with type or scope prefixes. Hungarian Pollution.

N7: Names Should Describe Side Effects - Names should describe everything that a function does, including side-effects. Don’t hide side effects within the name.

Clean Code - Chapter 17

1 month ago

Blue Theme by David