Ticker

6/recent/ticker-posts

Header Ads Widget

Responsive Advertisement

How do I choose the perfect names for variable of programming?

How do I choose the perfect names for variable of programming?

 1. What is a Variable?

The variable is the computer memory location that can store values for using and manipulating a program. According to the variables, it has two main parts. Those are names and data type. The two main parts mentioned above should be taken into consideration when declaring a variable. So the program and the developer can be more clearly understood. The developer assigns the required size storage space and correlates the name and data type form with this exact address. 

2. Variable Declaration

As we mentioned above, there are two main parts to consider when expressing a variable. Those are name and date type. There must be some order in declaring it. That is, the data type must be specified first and the name of the variable second. 

Variable Declaration in programming language
Variable Declaration
      Ex: ​<data type> < Name of the variable>;









3. Important points to consider when naming a variable

When naming a variable, it should always be given a meaningful nomenclature. Do not use x, y for the name of the variable. You should always use a meaningful name. It’s like car_prices,  employee_salaries. The name you give to the variable gives a complete idea of the program and is more clearly understood by the developer. The above explains that you should pay more attention to the ease of reading the code than the ability to write it.
Naming a variable for a C programming language
Example for good naming variable

4. Do not use the following names for variables

  • Avoid using numbers when naming variables.
  • Avoid using similar ideas names
  • Avoid names that sound similar
  • Avoid using special names reserved for programming languages (ex: int, return, if, while, for….)
  • C is case sensitive (uppercase and lowercase letters are different in C)
                   Ex. total , Total and TOTAL are three different variable names

If you have any different idea please leave a comment below and we can discuss it.

Post a Comment

0 Comments