Variable Naming Conventions

Variable Naming Conventions

Hi techies,

if(namingConventionSeemLikeHell) console.log("Please, take a coffee and stay with me")

Naming convention is a set of rules for choosing the character sequence to be used for identifiers which denote variables, types, functions, and other entities in source code and documentation.

Often times, you might get lost in what name to give a variable and it's quite sad that you might certainly end up declaring a weird variable name, sometimes it makes you feel like an amazing developer that makes a weird variable name in your codes. Actually you are an amazing developer indeed, maybe you are just a junior developer or an amazing developer with a non-professional coding skill. However, it might seem really annoying to a third party when reading your code from their end, you might have issues in project collaborations and contributions.

In my journey as a developer, i've made researches about cybersecurity on how to make my projects secure from hackers, i was expecting a very complex principle and guidelines to make my projects more secure. However, the first principle i learned was that being simple makes it a bit hard to be penetrated by other party, the other party might expect something more complex and could never taught it would be as simple as you made it, although the simplicity varies in programming and the level of professionalism.

Simplicity is more secure

Guidelines to naming conventions

I have made some nice and helpful guidelines to enhance your naming convention skill, you might want to take bit break off the coffee. lol

Code Readability and accessibility

Well-chosen identifiers make it significantly easier for developers and analysts to understand what the system is doing and how to fix or extend the source code to apply for new needs. For example, although

const b = 3
const c = 4
const a = b * c

is syntactically correct, its purpose is not evident. Contrast this with:

 weekly_pay = hours_worked * hourly_pay_rate;

which implies the intent and meaning of the source code, at least to those familiar with the context of the statement.

const nameOfDepartmentInEngineering = ['civil', 'mechanical', 'material science', 'aeronautics']

The word "naming" simply means defining an entity with respect to it desired features and characteristics, a cup is named "cup" because it has the feature of holding some amount of liquid, pain killer is named "pain killer" because it has the capability of killing pains, i'm outta context right ? nah nah lol

Yeah, the essence of naming variables is to define or explain its content and variables shouldn't be named base on instinct or experience but it should be named in such a way that it defines and explains it content.

Hints For Naming Variables

  • Lowercase and uppercase combination Naming

    const exampleOfCaseCombination = "using lowercase and uppercase to join variable names"
    
  • Underscore Naming

const example_of_character_combination = "using underscore to join variable names"
If you find it helpful, comment, like and share to fellow developers