General naming principles
Regardless of the specific Object-Oriented Programming (OOP) language you’re using, certain universal naming principles can help improve the clarity and maintainability of your code. These principles aim to ensure that names in your code provide sufficient information about their use and functionality.
Descriptiveness
Names should accurately describe the purpose or value of the variable, function, class, or method they are identifying. For instance, getSalary()
for a function is more informative than simply getS()
.
Consistency
Consistency in naming conventions is one of the most vital principles in writing clear and maintainable code. When you’re consistent with your naming throughout your code base, it becomes much easier to read, understand, and debug your code. The reason for this is that once a developer learns your naming pattern, they can apply their understanding across the entire code base, rather than having to figure out...