The Snake Ate The Camel

December 4, 2020 - by Sindhuri Kuppasad

Now that I have your attention, no we’re not off to visit a zoo, although admittedly, in the current times, that would be exciting. Instead, we’ll walk through some code and we might just meet some animals along the way.

Anyone who’s starting off learning how to code is going to realize pretty quickly that their usage of Shift keys has suddenly increased 10 fold. You may be instructed to type:




and then scream


So what’s going on? Enter coding standards.

Coding standards are nothing but a set of guidelines for a specific programming language that contain the recommended programming styles and best practices for various aspects of code. These usually cover a wide variety of subjects such as naming conventions, code structuring, block indentation, design principles as well as perspectives on code readability and maintainability. When learning any new programming language, it is important to understand the associated coding standards and follow them because these are specifically designed to result in good quality code.

Consider this - code usually contains different types of identifiers such as variables, functions and classes. If you don’t yet know what these are, don’t panic, just take my word for it. All these entities require names which are used to reference them throughout other parts of the code. Well, just call them a, b, c … right? Sure, but 5 contributors and 5000 lines of code later, everyone is confused about whether ‘h’ is a variable or a function. Okay, how about — V1, V2, V3 … for variables, F1, F2, F3 … for functions and so on. But another 5000 lines of code and maybe 2 months later, no one can remember what V8 means or what F16 does! Enter naming conventions.

“There are only two hard things in Computer Science: cache invalidation and naming things.”

— Phil Karlton

Naming conventions are a set of rules for choosing the character sequence to name identifiers in code that represent variables, functions, classes, packages, files, etc. In other words, it specifies what naming style to use for each entity in code. Naming conventions are aimed at reducing the effort to read, understand and maintain code by setting a standard. Here are some commonly used naming styles:



lowercase_with_underscore -- also called -- snake_case





UpperCamelCase -- also called -- PascalCase


And finally... drumroll

snake_ATE-THE-CAMEL_case -- Just kidding!

For instance, Python language’s coding guidelines recommend using snake_case for variable names, UPPERCASE_WITH_UNDERSCORE for constant names and PascalCase for class names, among other things. While this may feel like too much to remember and follow in the beginning, it becomes second nature with practice over time. :) By following these guidelines, it is immediately clear what a certain name refers to and one will be able to focus on the important parts of the code without having to worry and argue about the names. Naming conventions go much beyond just this, they can also specify things like maximum length, use of special characters as prefix or suffix, etc.

Now that you know what’s up with names in code, go forth and conquer the programming world!