What is Indentation, Documentation and Program Maintenance?

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++

filter_none

edit
close

play_arrow

link
brightness_4
code

#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;
}

chevron_right


Output:



b is greater than a

2. Using indentation in looping statements.

C++

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


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++

filter_none

edit
close

play_arrow

link
brightness_4
code

#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;
}

chevron_right


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.



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.