Maintenance

  1. Stong Cohesion/ Loose Coupling
  2. Check for bad input
  3. Data Scope
  4. Logging
  5. Documentation
  6. Design for Change
  7. Incremental Refinement

Software Lifecycle

Review

  1. Requirements
  2. Design
  3. Implementation
  4. Testing
  5. Installation
  6. Maintenance

Post-Release

After the first release, lifecycle focuses on either fixing bugs:

  1. Debug ⇆
  2. ⇆ Test
  3. Profile
  4. Optimize

… or adding new features:

  1. Add Feature
  2. Test ⇆
  3. ⇆ Debug

Defensive Programming

Cohesion & Coupling

Cohesion

[See managing complexity note]

Coupling

[See managing complexity note]

Mediators

Mediator: invokes a function indirectly through another function.

Bad Input

Example 1 (Bad)

float average(float *array, int size)
{
    float sum=0;
    int i;
    for(i=0; i<size; i++)
        sum = sum + array[i];
    return(sum/((double) size));
 }

Example 2 (Better)

float average(float *array, int size)
{
    float sum=0;
    int i;
    if (size ==0)
        return(DIV_BY_ZERO);
    for(i=0; i<size; i++)
        sum = sum + array[i];
    return(sum/((double) size));
}

Bad Arguments

C functions to avoid

Data Scope

Logging

Uses in Defensive Programming

  1. Used to capture program events.
  2. Used to trace program execution.

Log Messages

Documentation

Incorrect Documentation

Too Much Documentation

Absent Documentation

Intention

Incremental Refinement

Unit Testing

Machine Dependencies

Endianess

Endianess refers to the order in which the bytes in a word are organized.

Memory Alignment

Virtual Machines