Skip to main content

Consistency in style

Brief​

Be consistent with the conventions you choose (e.g. camelCase vs snake_case, prefix of member variables etc.).

Why bother?​

When your brain gets used to a convention you will find it easier to read and understand the code. On the contrary if a project breaks its own convention all the time it can be confusing.

To help you in this task you have formatting tools and static analysers which will do most of the job for you.

Don't be too religious​

You might think that the convention you use is the best – everyone does – but it's all about trade-offs and there is no one single right answer.

A new project is a great opportunity to give another convention a shot. Don't judge conventions solely on your expectations, because we are so used to the one we use that all the other feel weird at first sight. But by trying a convention for a few weeks your view of it will change. This happened to me with snake_case; I used to think that it was weird and ugly, but now I think this is the most readable convention of them all because the words are clearly separated and it helps a lot, especially with longer names.