Coding Guidelines Assignment Help | Coding Guidelines Homework Help

Coding Guidelines

Although writing 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 mush indicate their role in the program. In other words, they should be closely related tot eh entity they represent and module names should reflect their activity.

2.    GOTO: Minimize the use of GOTO statements. GOTO should be used sparingly and in disciplined manner. Only when the alternate 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 and indentation properly. If available, use automated tools like pretty printer to improve the layout/ appearance of the program.

4.    Information Hiding: Try to achieve minimum couplings between the modules using concept of information hiding. This means that modules must behave as black boxes to each other. It also means that a procedure is defined in terms of its purpose but not how it achieves that purpose. For example compute-house-tax procedure would be defined as procedure which calculates the house tax for an individual. The method of calculation can be changed from time to time and need not be available to other parts of the program. The only information of interest is the input and output parameters. The concept of information hiding is an important characteristic of object oriented methodologies and programming languages.

5.    Cohesive Procedures: The programmer must aim for highly cohesive modules i.e., each procedure or function in the program must perform only a single task. If a procedure handles too many tasks its logic can be herd to comprehend and bugs can easily occur.

6.    Minimize Coupling: Parameter passing is a good programming practice, but with too many parameters the code becomes difficult to manage. Procedures with many prompters are highly coupled ; they have lots of links to other procedures, where ever possible try to minimize these links. However, global variables should not be used instead.

7.    I/O Behaviour: All I/O should use a proper format:
•    All real number output should be formatted in decimal form unless scientific notation is appropriate.

•    All input from the keyboard should be preceded by a prompt telling the user what format is expected.
For example, please input the date in mm/dd/yy format.

•    Label all output values.

8.    Robustness: A program is robust if it does something planned even f exceptional conditions. A program might encounter exceptional conditions in form of incorrect input, the incorrect value of some variable or overflow. A program should try to handle such situations. In general, a program should check for validity of inputs, where ever possible and should check for possible overflow of the data structures. If such situations do arise, the program should not just “crash” or “core dump”, rather it should produce some meaningful message and exist gracefully.

9.    Side Effects: When a module is involved, it sometimes has side effects of modifying the program state beyond the modification of parameters listed in the module interface definition, for example, modifying global variable. Such side effects should be avoided where ever possible, and if a module has side effects, they should be properly documented.

For more help in Coding Guidelines click the button below to submit your homework assignment