DEV Community

Cover image for Some Reasons Why You Should Follow Naming Conventions
Amr Saeed
Amr Saeed

Posted on • Originally published at

Some Reasons Why You Should Follow Naming Conventions

Writing clean and readable code is not an easy task. It requires you to keep reading about good practices and apply them as much as you can to avoid the bad ones.

Today we're going to talk about the benefits of one of those practices to understand their importance. But before touching upon this, let's understand what does naming conventions mean.

Naming conventions are some rules that help you to name things in your code such as variables, functions, and classes.

One of the common naming conventions which are adopted by many programming languages such as Java is the Camel Case. In Camel Case, you name your variables and functions in the following way myNameIsAwesome. The first word starts with a lower case letter followed by as many words as you want but they start with upper case letters.

Python and similar languages such as Ruby adopt another naming convention which is Snake Case my_name_is_awesome. You can clearly tell the difference between Camel Case and Snake Case.

Now it's time to understand why naming things in your code is very important. You might see it as a trivial task with no benefits at all and you don't have to care about it. But believe me, it is not a waste of time as it looks like.

Unified Style Enhances Readability

Imagine a large project with hundreds of developers who participate. If every developer decided to name variables and functions with their own style, the project is going to be a mess.

Developers who follow the same naming convention across the project contribute to its readability. The project will look as if it was written by a single person.

Differentiate Items by Their Names

Another advantage of following naming conventions that also contributes to the project readability is that you can differentiate items easily by their names. If in Java, for example, you find an item that is named in Camel Case myItem, that means it's a variable, object, or method. If it's named in Pascal Case MyItem, that means it's a class. If it's named in Screaming Snake Case MY_ITEM, that means it's a constant.

public class Circle {
    private static final double PI = 3.14;
    private double radius;

    public Circle(double radius) {
        this.radius = radius;

    public double getArea() {
        return PI * radius * radius;

public class Main {
    public static void main(String[] args) {
        Circle circle = new Circle(5);
        double area = circle.getArea();
Enter fullscreen mode Exit fullscreen mode

Search Becomes Easier

Following a naming convention makes it easy for you to search for items in the project. If for example, you want to find the method that is responsible for authenticating users, you'll be expecting to find it with the name login or signIn for the Camel Case convention.

The same idea applies when you're using a built-in class such as ArrayList in Java. If you want to find the size of an ArrayList object, you'll be expecting to find a method with the name length or size.

ArrayList Size

More Focus on the Necessary Details

Time is one of the most valuable resources, if not the most valuable. When it comes to software projects, we always want to achieve more in less time. To do that, we've to make repetitive tasks such as naming things much faster. As you can see, following the naming convention of the programming language we use can contribute to that. By doing so, we're reducing the debates among the developers about the best naming convention to follow, because we're following the standard. In other words, we let the developers focus on the necessary details.

Convention Over Configuration

Convention over configuration is a software design paradigm used by software frameworks that attempts to decrease the number of decisions that a developer using the framework is required to make without necessarily losing flexibility. Wikipedia

Simply, Convention Over Configuration is an approach that is used by modern frameworks. It makes a deal with you. If you follow the conventions that the framework adopts, the framework will automatically do configuration tasks for you. Otherwise, you'll have to do them manually by yourself and lose this advantage.

For example, the framework may till you to name your classes in the Pascal Case naming convention User so that it can automatically create a corresponding table in the database with the name users for you. If you decided to name the class with another naming convention __user the framework won't do the mapping task for you and you've to write some configurations to create the table correctly. That's because you didn't follow the conventions that the framework adopts.

Now you understand why following naming conventions is essential, and although it seems like a trivial task, it really contributes to your projects.

If you know any other advantage for following naming conventions, please share it with us.

Top comments (2)

klauseverwalkingdev profile image
Klaus Ferreira

Great article :)

amrsaeedhosny profile image
Amr Saeed

Thanks Klaus glad you liked it.