DEV Community

Cheikh Tidjane Konteye
Cheikh Tidjane Konteye

Posted on

Coding with an accent

After few years working in the software industry, I realized that most of the companies do not really care enough about conventions. They mostly focus on the "Getting Things Done" and keep using accent - sometimes unconsciously - in their code base which make the integration of newcomers very difficult.

Natural Languages & Software Languages

We use natural languages to communicate with humans as we use software languages to communicate with computers. The fact is when we code we do not communicate only with the computer but also with other coders. So basically we want other to understand what we do.
As you can feel the accent of a french native speaker speaking in English without respecting words pronunciations, you can also feel the accent of a developer from Java world coding in Python without respecting conventions. It's the same thing when a developer comes from technology A and apply its conventions to a technology B.
In natural languages, accent is not that bad. However, it can provoke a big mess in software development.

Avoid using accent

I one day worked on a project where the technology used was Python/Django. The first time I joined the team - as usual - they gave me the requirements to read. After reading them and jumped into the project, I was a little lost. The project architecture did not respect the Django conventions and there were no documentation in the project saying it. It took me time to get into it and start coding. "Why you didn't use the default architecture?" "Is there any purpose on changing it?" I asked. "No, We've used to design like that" one of my teammate answered.
It was not the only weird thing I've found. For each python .py files, there was only one class that has the same name as the file. Then I realized those guys are from Java or C# where the convention is to have only one class for each file (required in Java, preferred in C#). In fact in those languages, files are not modules whereas they're in Python. So they were coding with accent.

The following snippets shows two Python code: the first with accent (brought from Golang) and the second with Python's conventions:

Python code with Golang accent:

 def multiply(x, y):
    error = False
    result = None
    if not x.isdigit() or not y.isdigit():
        error = True
    else:
        result = x * y
    return result, error

 result, error = multiply(5, 4)
 if not error:
    print(result)
Enter fullscreen mode Exit fullscreen mode

Python code without accent:

 def multiply(x, y):
     if not x.isdigit() or not y.isdigit():
         raise ValueError("inputs should be digits")
     return x * y

 # Python doesn't use errors. It uses exceptions.
 try:
    result = multiply(5, 4)
 except ValueError as e:
    print(e)
 else:
    print(result)
Enter fullscreen mode Exit fullscreen mode

This shows how bad it is to code with accent. It's because people usually don't read the official technologies documentations. They pick a technology and apply a foreign conventions to it. It makes the code harder to understand.

Don't fall into the trap.

Top comments (1)

Collapse
 
foxy4096 profile image
Foxy4096

well its good that I don't write JavaScript with python accent.