Open In App

What is Indentation, Documentation and Program Maintenance?

Last Updated : 02 Jul, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

Indentation improves the readability of the code. It is mainly used for code inside looping statements, control structures, functions etc. as good intended code is easy to maintain and is good looking. It makes the code more readable and easy to understand. Some programming languages like Python made indentation mandatory instead of using brackets, It makes code easy to read and understand.

Some Rules for indentation are:

  • Each nested block should be properly indented and spaced with a tab space.
  • All braces should start from a new line then the code comes following the end braces from a new line.

Example of Some Good Indentation Practices

1. Using Indentation in conditional statements.

C++




#include <iostream>
using namespace std;
  
int main()
{
    int a = 10, b = 20;
    if (a > b) {
        cout << "a is greater than b";
    }
    else {
        cout << "b is greater than a";
    }
    return 0;
}


Output:

b is greater than a

2. Using indentation in looping statements.

C++




#include <iostream>
using namespace std;
  
int main()
{
    for (int i = 0; i < 10; i++) {
        cout << "GeeksforGeeks"
             << "\n";
    }
    return 0;
}


Output:

GeeksforGeeks
GeeksforGeeks
GeeksforGeeks
GeeksforGeeks
GeeksforGeeks
GeeksforGeeks
GeeksforGeeks
GeeksforGeeks
GeeksforGeeks
GeeksforGeeks

Documentation

Documentation is a very important aspect of programming. Good documentation in programs make it easy for user to read and understand the code. This is done by inserting comments in the necessary places to make the code readable and more understandable for user. Documentation is basically for users of the code to understand it even without the help of programmer. Add Comments in code and explain the code line and the code will be well Documented.

Example: 

C++




#include <iostream>
using namespace std;
  
// Main function
int main()
{
    // Initializing variable a by 10 and b by 20
    int a = 10, b = 20;
    
    // If a is greater than b go inside if block
    if (a > b) {
        
        // Print a is greater than b
        cout << "a is greater than b";
    }
    
    // If a is not greater than b go in else block
    else {
        
        // Print b is greater than a
        cout << "b is greater than a";
    }
    
    // End of main function
    return 0;
}


Program Maintenance

Once the Program is made, it is saved and stored as a software package. After some time if the program needs improvement or modification, the saved program is modified and saves effort and time as programs need not to made from the very beginning. Hence Modifications will meet the purpose only. Program maintenance is done as:

  • Keep the last program.
  • Modify the program for required improvements.
  • Do not make new program from scratch, just use the last saved program.
  • Save time and effort.


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads