Clean Code – Rules For Name Crafting (Series)
July 30, 2019
The very first task that we do while starting to program is naming from the creation of directory to files, to classes, to functions. Name is everywhere, we cannot escape it, and we do so much of naming, we should be fulfilled if we can do it better.
Beginners do marvel at how the seniors snap out great names that fit the context to be applied. How the names are crafted seem like magic, they end up seeing themselves not so close when they see that wack name their brain could best provide.
Fortunately, Micheal Jordan was not born a perfect athlete, and he learned it all. We can learn how to craft proper names by following a set of guidelines laid out by experts in the field of computer programming.
Robert stated below rules, and we also see them as essential for naming considerations in our codebase:
- Always use intention revealing names
- Avoid disinformation
- Make meaningful distinctions
- Use pronounceable names
- Use searchable names
- Avoid encodings
- Avoid mental mappings
- Do not be cute
- Pick one word per concept
- Do not Pun
- Use solution domain names
- Use problem domain names
- Add meaningful context
- Do not add context gratuitously
It is an undeniable list with thoughtful and straightforward rules, and we will be going over all of them throughout the next few posts.
By the end of this series, we would be informed of why we make bad names, and how we can make good ones. Let us get started with the Rules for name crafting – Part One.
We will meet on the other side!Edit on githubTweet