1 Detailed Design Representations (Chapter 9 of Code Complete) Steve Chenoweth CSSE 375, Rose-Hulman Based on Don Bagert’s 2006 Lecture
2 Today (Mon, Sep 17, 2007) Review Reuse & Reusability Two topics – Detailed design & pseudocode – this Maintenance Management & Organization Tonight – Turn in your team’s maintenance plan Note: Exam, Wed night, Oct 3, 7 – 9 PM
3 Outline Detailed Design Representations Background Pseudocode Other Representations
4 Background In some ways, detailed design is becoming a lost art Nowadays, programmers often write source code directly from high-level design Is this a good thing?
5 What is Pseudocode? An informal, natural-language notation for describing an algorithm Advantages: Structure is similar to source code Can describe various levels of detail
6 Example: Whether or not an integer is a prime number – 1/3 First iteration (keeps to definition of prime number): If the integer < 2 Return false Else Determine whether there is a factor between 2 and the integer minus 1 If no factor is found Return true Else Return false End If
7 Example: Whether or not an integer is a prime number – 2/3 Second iteration (Takes advantage of known facts): If the integer < 2 Return false Else if the integer = 2 Return true Else if the integer is even Return false Else Determine whether there is a factor between 3 and the square root of the integer If no factor is found Return true Else Return false End If
8 Example: Whether or not an integer is a prime number – 3/3 Third iteration (Determination loop and variables included): If n < 2 Return false Else If n = 2 Return true Else If n is even Return false Else FactorNotFound = true Index = 3 While FactorNotFound and Index <= the square root of n do If Index is a factor of n FactorNotFound = false Else Index = Index + 2 End if End While Return FactorNotFound End if
9 Group Discussion: Do you think that pseudocode is useful?
10 Other Detailed Design Representations Flowcharts Classic Examples: FlowchartingTechniques-GC pdf (from 1969!) FlowchartingTechniques-GC pdf Structured Example: Control Structure Diagrams jGRASP / /
11 jGRASP Exercise (if we have time)