Today I will discuss top coding tips which can be applied to any particular programming language. Also the tips will help you to write self documented programs which are easy to maintain and understand by anyone. 

Design first then code

Days are gone when we use to take pen and paper and write the pseudo code first draw the flow diagrams of the program. And at the end write the code on computer. Days are changed but still we need to apply SDLC (Software Development Life Cycle) on every program we create. This makes the program bug/error free as well as maintenance easy. I suggest you read Martin Fowler's excellent article Is Design Dead? which explains it in more details.

Variable and function Naming

Variable names are made up of characters and digits. There are lof of ways to name your variables and function. I will describe the way I do the naming for variables and functions regardless of any programming language.


Always start the name with the first character of the variable type or the complete variable type name. For example

To declare an integer variable: int iVarName;
To declare a character variable: char cVarName;

To declare an integer variable with variable type name first: intVarName;
To declare a character variable with variable type name first: charVarName;

Also the name should describe the usage of the variable. It should not be just iMyVar or sVar1. So if you want to declare some variables to hold the properties of a car object. Then you can declare the variables like:


Functions should also have meaningful names, and first character of each word should be capital. There are two ways to name give a name to the functions. Eiterh the first character is always in lowercase then the secod word is in propercase. This is mostly done on Linux platforms, but in Microsoft technologies functions are mostly declared with first character in capital.

Always write Comments

Comments describe what’s happening and how the specific code is being done. There are certain ways to write comment in C/C++ program.

I would advise to use single line comments for statements and multiline comments at the start of a class or a function. So you could write

Common coding standards

There are lots of ways to declare variables, functions constants, write statements and give comments to a block of code. You can write very good code with proper indentation, comment the code and write the code in a correct syntax. The actual bottom line is that, whatever the coding standard you use, it should be followed throughout the program development. If you use initial character of every variable type name at the beginning of each variable then it must be the same for all the variables declared in the program.

Keeyp an eye on this blog as in the next few days I would be posting more tips on making your program more memory efficient and processing efficient.