Techniques used in developing well-written code

The use of good programming practice, including:
A Clear Uncluttered Mainline

  • Software products should be developed using a clear modular approach
  • In general, the mainline should be clear and uncluttered so it is easy to follow and identify subroutine calls
  • This means that the subroutines are coded and tested independently which is better for maintenance reasons

One Logical Task Per Subroutine

  • The name should be able to describe the algorithm succinctly
  • When the algorithm becomes longer than about one page it becomes more difficult to understand and therefore to maintain

Use of Stubs

  • A stub is an incomplete function that has the same name and interface as the final form but simpler
  • Stubs usually only contains an output statement to indicate the function was called
  • Is used in testing the implementation of a program

Appropriate Use of Control Structures and Data Structures

  • Control structures should only use recognised statements such as pre or post test loops
  • The condition for the loop should determine the only exit from the loop
  • There shouldn’t be jumps that cause control to exit a loop or selection unexpectedly
  • Types and unusual cases should be considered when making repetition or selection structures
  • Data structures such as arrays, records, array of records and others should be selected and designed to assist processing

Writing for Subsequent Maintenance

  • Coding should be done in such a way that future maintenance programmers can easily update the code
  • Good ways to make the code accessible for maintenance includes:
    • Clear documentation within the code
    • appropriate identifiers names
    • indenting within control structures

Version Control and Regular Backup

  • During coding all programmers should regularly save their work to prevent loss and allow for different versions of the program or module
  • Regular backup should be done to various devices instead of single one to prevent absolute loss
  • Version control allows complete applications to be continuously developed with regular version being released to users
  • Version control allows reversion to a previous version any time in the future
  • Version control systems are routinely used by teams of programmers because it routinely does all of the above functions

Recognition of Relevant Social and Ethical issues

  • Social and ethical issues should be considered when developing
  • Some of these include:
    • Intellectual property when code written by others is used
    • Thorough testing to ensure software performs correctly
    • Documentation for future developers and maintainers

The process of detecting and correcting errors, including:
Types of Errors

  • Syntax errors
    • Syntax errors are involved in the translation process
    • Syntax errors prevent the translating the high level code to object code
    • Once a syntax error has been detected, it is usually a simple task to correct
  • Logic errors
    • Logic errors are the result of syntactically correct code that does not complete the required task
    • Logic errors are the most difficult error to correct
    • It is impossible for the development environment to detect logic errors
  • Runtime errors
    • Runtime errors are errors that occur while executing, they can include:
    • Arithmetic errors
      • Involves the incorrect use of data types and data structures
      • Usually occurs when result cannot be stored properly
    • Division by zero
      • Undefined arithmetic operation that causes error
    • Inappropriate memory locations
      • Error occurs when inappropriate memory locations are accessed, eg array range

Methods of Error Detection and Correction

  • Use of flags
    • Flags are a marker placed in the code to signal a change in status
    • Code that will change the value of the flag is added to an appropriate location
  • Methodical approach to the isolation of logic errors
    • The programmer may use the comment tool to stop code from running
    • Programmers may also comment out blocks of code and systematically find the precise location of an error
  • Use of debugging output statements
    • Debugging output statements are temporary lines of code added to display the value of a variable
    • It may also be used to state that a particular part of code has been reached
  • Peer checking
    • Involves the checking of the code along with other person/programmer
  • Desk checking
    • Test data is used to compare the actual result with the expected results
    • Use structured walk
    • through to step through the code and find where errors occur
    • Deskchecking should be performed on sub and whole programs
  • structure walk through
    • structured walk-through are more formal than peer checks
    • No attempt is made to correct problems as they stand but instead get feedback
    • Made to evaluate the design at different levels

The use of software debugging tools
Break Point

  • A simple technique which may temporarily or permanently stopping execution
  • Used to check variable contents before and after processes occur

Resetting variable contents

  • The data stored in a variable can be changed while the program is running
  • Can be used to check which values are giving errors

Program traces

  • Allows the programmer to view progress of the program execution in detail
  • Particularly useful for following the progress of the program through nested loops or complicated selections

Single Line stepping

  • A variable trace enables the programmer to observe the variable changing throughout the program

Leave a comment