400 likes | 424 Views
Learn top-down and bottom-up design approaches, object-oriented design methods, and tools for documentation in software systems. Understand decision tables, control-flow diagrams, UML, and more.
E N D
Chapter 2.1 Program Design and Documentation
System/Program specifications System/Program design Top-down & Bottom-up design Object Oriented design Tools for system/program documentation Decision tables Control-flow & Nassi-Shneiderman diagrams Data-flow diagrams State diagrams Unified Modeling Language Summary
System/Program specifications System/Program design Top-down & Bottom-up design Object Oriented design Tools for system/program documentation Decision tables Control-flow & Nassi-Shneiderman diagrams Data-flow diagrams State diagrams Unified Modeling Language Summary
What should the system/program do ? Formally: Set of all possible inputs {I} Set of all possible outputs {O} Function mapping all elements of {I} into elements of {O} Possible for simple and small programs Unfeasible for large scale systems System/Program specifications
None Many Interactions with other programs Number of users Only the author 1 3 Many, 3 9 The effort of Specifying
Specifications for large scale systems ? Make reasonable set of specifications REPEAT 2.1 Build prototype 2.2 Evaluate prototype 2.3 Update specifications UNTIL satisfaction of (potential) users Write down final specifications System/Program specifications
System/Program specifications System/Program design Top-down & Bottom-up design Object Oriented design Tools for system/program documentation Decision tables Control-flow & Nassi-Shneiderman diagrams Data-flow diagrams State diagrams Unified Modeling Language Summary
The Cost of Softwarefor large systems During design and coding efforts should be made to reduce the cost of debugging and maintenance
System/Program specifications System/Program design Top-down & Bottom-up design Object Oriented design Tools for system/program documentation Decision tables Control-flow & Nassi-Shneiderman diagrams Data-flow diagrams State diagrams Unified Modeling Language Summary
Top-down design: From global to detail Decompose the problem in simpler subproblems Further decompose subproblems UNTIL all subproblems have trivial solutions Bottom-up design: From detail to global Solve some small problems that might be useful for solving the big problem Use the partial solutions for assembling a global solution Design Methods
Specifications : Given : A car with a flat tire Wanted : Instructions for fixing it Strategy choice : Wait with a smile until somebody fixes it … Call a repair service Try to repair yourself Example : Repairing a flat tire
WHAT IS A PROGRAM ? PROGRAM = Description of data + Actions to perform upon these data
“Data” Car, Defective wheel, Spare wheel, Tools. Actions All that need to be done with the Car, the Defective wheel, the Spare wheel and the Tools in order to solve the problem. Repairing a flat tire“Data”and Actions
Inspect the spare wheel If available and in good condition, Then, repair yourself Else, you will need to call help Repairing a flat tireTop level design of actions
Fetch the tools Fetch the spare wheel Exchange defective and spare wheels Store defective wheel Store tools Repairing a flat tireRefinement of “repair yourself”
Tools : Jack : device to lift a car Wrench : device to loose or fasten bolts Repairing a flat tireRefinement of “tools”
REPEAT loose one bolt with wrench UNTIL all bolts loose; Lift car with Jack; REPEAT remove one bolt UNTIL all bolts removed; Remove defective wheel; Put spare wheel in place; REPEAT replace one bolt UNTIL all bolts in place; Lower car with Jack; REPEAT fasten one bolt with wrench UNTIL all bolts fastened; Repairing a flat tireRefinement of “Exchange defective and spare wheels”
System/Program specifications System/Program design Top-down & Bottom-up design Object Oriented design Tools for system/program documentation Decision tables Control-flow & Nassi-Shneiderman diagrams Data-flow diagrams State diagrams Unified Modeling Language Summary
Problem : If a data item is slightly changed, the entire program needs to be checked. Solution : Group data with description of all actions that can be performed upon such data Access data exclusively through the actions predefined for these data Object = data + actions to access it. Object oriented Design
Instance of the object : MyJack Possible actions : Fetch Inspect Store Lift a car Lower a car Repairing a flat tireObject-oriented style Object Jack =
System/Program specifications System/Program design Top-down & Bottom-up design Object Oriented design Tools for system/program documentation Decision tables Control-flow & Nassi-Shneiderman diagrams Data-flow diagrams State diagrams Unified Modeling Language Summary
Repairing a flat tireDecision Table OK Not OK Spare Wheel Tools Available & OK Repair yourself Get Help No good tools available Try to borrow tools Get Help
System/Program specifications System/Program design Top-down & Bottom-up design Object Oriented design Tools for system/program documentation Decision tables Control-flow & Nassi-Shneiderman diagrams Data-flow diagrams State diagrams Unified Modeling Language Summary
Spare Wheel OK ? Get Help Repair yourself Repairing a flat tireTop-level Controlflowchart Yes No
Get Tools Get Spare Wheel Change Wheel Store Bad Wheel Store Tools Repairing a flat tireRefinement of “repair yourself” Spare Wheel OK ? No Yes Get Help Repair yourself
Repairing a flat tireRefinement of “Get Tools” Tools present & OK ? Yes No Try borrowing Tools Got Tools or Tired ? Pick up the Tools No Yes Tools present & OK ? Yes No Help Needed !!!
Repairing a flat tireAdapted refinement of “Get Tools” Tools present & OK ? Yes No Try borrowing Tools Got Tools or Tired ? Pick up the Tools No Yes
Repairing a flat tireImproved top-level design Spare Wheel OK ? No Yes Fetch Tools Tools OK ? No Yes Get Help Repair yourself
Selection Statement selector = a ? Tasks to be done if selector = A Yes No selector = b ? Tasks to be done if selector = B Yes No selector = c ? Tasks to be done if selector = C Yes No Tasks to be done if no criteria OK
Selection Statement selector selector selector # a selector # b selector # c selector = a selector = b selector = c Tasks to be done if selector = B Tasks to be done if selector = C Tasks to be done if no criteria OK Tasks to be done if selector = A
Iteration Statement Initialization Loopbody, part 1 Termination Test Finish Continue Loopbody, part 2
Iteration Statement Initialisation Loopbody Part 1 Termination Condition Loopbody Part 2
Tools present & OK ? Yes No Get your own tools Try to borrow tools Spare Wheel ? OK Not OK Fetch Tools Until You got tools OR you are tired Tools ? OK Not OK Get Help Get Help Repair Yourself Get spare wheel Change wheel Store bad wheel Return tools Repairing a flat tire
System/Program specifications System/Program design Top-down & Bottom-up design Object Oriented design Tools for system/program documentation Decision tables Control-flow & Nassi-Shneiderman diagrams Data-flow diagrams State diagrams Unified Modeling Language Summary
Data-flow Diagrams Bad Wheel Spare Wheel Tools FETCHED REMOVED MOUNTED STORED STORED
System/Program specifications System/Program design Top-down & Bottom-up design Object Oriented design Tools for system/program documentation Decision tables Control-flow & Nassi-Shneiderman diagrams Data-flow diagrams State diagrams Unified Modeling Language Summary
Driving Successful help Done Puncture Flat tire Spare wheel OK No good Spare wheel Need help Good spare wheel No success No tools Try borrow tools Tools OK Success Repairing State DiagramsFlat tire problem
State DiagramsElectronic lock Waiting 1st digit Spontaneous transition First digit entered Waiting 2nd digit Opening door Second digit entered Wrong Key Waiting 3rd digit Third digit entered Good Key Testing key
System/Program specifications System/Program design Top-down & Bottom-up design Object Oriented design Tools for system/program documentation Decision tables Control-flow & Nassi-Shneiderman diagrams Data-flow diagrams State diagrams Unified Modeling Language Summary
Tool for supporting / documenting object oriented designs Applicable to the Organizational level System level Program level Set of different diagrams, including Class diagrams (= objects and their static relations) Interaction diagrams Activity diagrams (= extended control flow diagrams) State diagrams Deployment diagrams Unified Modeling Language