To develop a good program certain rules and guidelines are essential. The guidelines help us to create good and readable programs. There are many methods available, let us see some of them.
- Meaningful names for identifiers:
- When a program is to be executed, it uses variables, function name, user defined data etc.
- All the names which are used for identification should be simple and clear to use.
- While dealing with identifiers, the following rules are to be followed.
- Use proper names for variables, functions, procedures, etc.
- Don't Use similar names.
- Have a good scalable identifier to have better readable and clarity program.
- Clarity of expressions:
- Expressions are very important in a program.
- There should be a clear expression.
- The steps to be followed are:
- Avoid programming tricks whose intent will not be obvious to a reader.
- Use standard function in expression
- Using comments and indentation:
- Comments are essential in a program to provide the user a clear guideline about the program.
- Indentation makes the program more readable and clearer.
- The comments and indentation provide a clear and readable form of program to the user.
- For example
int a,b,c; // declaration of the variables.
cin >> a >>b>>c; // getting the input
cout<<a <<b <<c; // printing the output
- Insert blank lines and blank spaces:
- The insertion of blank lines and blank spaces also enhance the clarity of a program.
- The blank lines between a set of code helps to have a better readable form of program.
- The blank space between the words will also provide a readable form of program.
|Note: To have a better program, concentrate much on the content. that is, write short and simple lines of statements. So that it will be easily understood by the user.|