// CustomerList is not a list at all, its an array
Customer CustomerList; Customer Customers;
// what exactly is status?
bool status; bool IsValidSubmission;
// Information can be anything
void GetInfo(); void GetRegisteredUsers();
// method code is registering users and also sending them welcome email
I have highlighted the problem with each declaration in code above with a comment and then tried to fix it in the right hand side. If you read both names, you will see that the ones on the right are clearer and much more precise. Finally in the last example, I have highlighted a very common problem that I see very frequently in code, the method is doing much more than what it’s name says.
It is extremely important to come up with a naming convention and then stick to it. It does not matter if you want to call your method Get or Fetch but once you have established your naming convention, you must stick to it, the last thing you want to see in a code base is every developer coming up with their own naming convention.
Class names should be Noun or Noun Phrases
Classes are objects, objects that represent things we want them to model, so it makes perfect sense to use nouns or noun phrases when naming your classes. Naming your class Account, Transaction, AccountHolder, WireTransfer etc makes perfect sense and it also makes them searchable.
Method names should be Verb or Verb Phrases
Methods represent behavior therefore their names should ideally be a verb or verb phrase like Save(), SendMessage(), RedirectToHomePage() etc. what Robert Martin also preaches is to make your methods as small as possible, there is no such thing as a too small function. Once you have written a method, strive to make it smaller, once done, strive to make it even smaller 🙂
Naming for me is by far the most important step in making your code cleaner and easier to understand, it is the first rule for writing clean code. Next time you are writing code, try to come up with better names for your code segments, I am sure this will prove to be a giant step towards writing clean code.