Blog | Programming Guidelines

Computer programming is a process of writing an executable computer program for accomplishing a specific computer task. Although writing the programs is an art, however, there should be some minimum guidelines that should be followed while writing programs.

  1. Name:
    Define the variable names as per programming language rules. Use proper names for variables i.e, they must indicate their rule in the program. In other words, they should be closely related to the entity they represent and modules name should reflect their activity.
  2. GOTO:
    Minimize the use of GOTO statements. GOTO should be used sparingly and in a disciplined manner. Only when the alternative of using GOTOs is more complex; then only think of using GOTO statement.
  3. Program Layout:
    Document the program properly. Avoid meaningless comments. in order to make the program easy to read, use spaces, blank lines, indentation properly. If available, use automated tools like pretty-printers to improve the layout of the program.
  4. Information Hiding:
    Try to achieve minimum coupling between the modules using the concept of infom=ramtion hiding. This means that the module must behave as blank boxes to each other. It also means that a procedure is defined in terms of its purpose but not how it achieves that purpose.
  5. Cohesive Procedures:
    The programmer must aim for highly cohesive modules i.e, each procedure of function in the program must perform only a single task. If a procedure handles to many tasks than its logic can be hard to comprehend and bugs can easily occur.
  6. Minimise Coupling:
    Parameter passing good programming practics, but with too many parameters the code becomes difficult to manage. Procedures with many parameters are highly coupled; they have lots of links to other procedures, where every possible try to minimize these links. However, global variables should nor=t be used instead.
  7. I/O behaviour:
    All I/O shoul duse a proper format:

    • All real number output should be format in decimal form unless scientific notation is approprite.
    • All input from the keyboard should be preceded by a prompt telling the user what format is accepted.
    • Label all input values.
  8. Robustness:
    Robustness is the ability of a program to recover itself from any error during the runtime. It describes the reliability of the program under extreme conditions.


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.