What is Indentation, Documentation and Program Maintenance?
Last Updated :
02 Jul, 2020
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.
Similar Reads
Statement, Indentation and Comment in Python Here, we will discuss Statements in Python, Indentation in Python, and Comments in Python. We will also discuss different rules and examples for Python Statement, Python Indentation, Python Comment, and the Difference Between 'Docstrings' and 'Multi-line Comments. What is Statement in Python A Pytho
7 min read
What are Identifiers in Programming? Identifiers are names given to various programming elements, such as variables, functions, classes, constants, and labels. They serve as labels or handles that programmers assign to program elements, enabling them to refer to these elements and manipulate them within the code. In this article, we wi
3 min read
What is an IDE? - Integrated Development Environment An IDE (Integrated Development Environment) is software that combines commonly used developer tools into a compact GUI (graphical user interface) application. It is a combination of tools like a code editor, code compiler, and code debugger with an integrated terminal.Integrating features like softw
8 min read
What is Syntax? Components, Rules, and Common Mistakes Programming languages serve as the foundation for building software applications, enabling developers to communicate instructions to computers effectively. A critical aspect of programming is understanding and implementing syntax and structure. In this article, we'll delve into the significance of p
10 min read
Project Documentation: 15 Essential Project Documents Effective project documentation is key to successful project management. It serves as a central place for important information, helps in making decisions, and ensures good communication and project continuity. In this article, we will learn why documentation is important, list the essential documen
8 min read