Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 2.1 Program Design and Documentation. Summary System/Program specifications System/Program design –Top-down & Bottom-up design –Object Oriented.

Similar presentations


Presentation on theme: "Chapter 2.1 Program Design and Documentation. Summary System/Program specifications System/Program design –Top-down & Bottom-up design –Object Oriented."— Presentation transcript:

1 Chapter 2.1 Program Design and Documentation

2 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

3 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

4 System/Program specifications 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

5 The effort of Specifying Interactions with other programs Number of users Only the author Many, NoneMany 1 9 3 3

6 System/Program specifications Specifications for large scale systems ? 1Make reasonable set of specifications 2REPEAT 2.1 Build prototype 2.2 Evaluate prototype 2.3 Update specifications UNTIL satisfaction of (potential) users 3Write down final specifications

7 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

8 The Cost of Software for large systems During design and coding efforts should be made to reduce the cost of debugging and maintenance

9 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

10 Design Methods 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

11 Example : Repairing a flat tire 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

12 WHAT IS A PROGRAM ? PROGRAM = Description of data + Actions to perform upon these data

13 Repairing a flat tire “Data” and Actions “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.

14 Repairing a flat tire Top level design of actions Inspect the spare wheel If available and in good condition, –Then, repair yourself –Else, you will need to call help

15 Repairing a flat tire Refinement of “repair yourself” Fetch the tools Fetch the spare wheel Exchange defective and spare wheels Store defective wheel Store tools

16 Repairing a flat tire Refinement of “tools” Tools : –Jack : device to lift a car –Wrench : device to loose or fasten bolts

17 Repairing a flat tire Refinement of “Exchange defective and spare wheels” 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;

18 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

19 Object oriented Design 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.

20 Repairing a flat tire Object-oriented style Instance of the object : MyJack Possible actions : Fetch Inspect Store Lift a car Lower a car Object Jack =

21 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

22 Repairing a flat tire Decision Table Spare Wheel Tools Available & OK No good tools available OKNot OK Repair yourself Get Help Try to borrow tools

23 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

24 Repairing a flat tire Top-level Controlflowchart Spare Wheel OK ? Get Help Repair yourself No Yes

25 Repairing a flat tire Refinement of “repair yourself” Spare Wheel OK ? Get Help Repair yourself NoYes Get Tools Get Spare Wheel Change Wheel Store Bad Wheel Store Tools

26 Repairing a flat tire Refinement of “Get Tools” Tools present & OK ? Tools present & OK ? Pick up the Tools Try borrowing Tools NoYes Got Tools or Tired ? Yes No Help Needed !!!

27 Repairing a flat tire Adapted refinement of “Get Tools” Tools present & OK ? Pick up the Tools Try borrowing Tools NoYes Got Tools or Tired ? Yes No

28 Repairing a flat tire Improved top-level design Spare Wheel OK ? NoYes Tools OK ? Fetch Tools Yes No Get Help Repair yourself

29 Selection Statement No 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 Tasks to be done if no criteria OK

30 Selection Statement selector Tasks to be done if selector = A selector = a Tasks to be done if no criteria OK selector # a selector # b selector # c Tasks to be done if selector = B Tasks to be done if selector = C selector = bselector = c selector

31 Iteration Statement Termination Test Initialization Loopbody, part 1 Loopbody, part 2 Continue Finish

32 Iteration Statement Initialisation Loopbody Part 1 Loopbody Part 2 Termination Condition

33 Repairing a flat tire Spare Wheel ? Not OK OK Get Help Fetch Tools Tools ? Get Help Repair Yourself Not OK OK Tools present & OK ? YesNo Get your own tools Try to borrow tools Until You got tools OR you are tired Get spare wheel Change wheel Store bad wheel Return tools

34 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

35 Data-flow Diagrams Bad Wheel Tools Spare Wheel FETCHED STORED MOUNTED STORED REMOVED

36 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

37 State Diagrams Flat tire problem Driving Flat tire Need help Good spare wheel Repairing Try borrow tools Puncture No good Spare wheel Successful help No success Spare wheel OK Done No tools Tools OK Success

38 State Diagrams Electronic lock First digit entered Waiting 1st digit Testing key Waiting 2nd digit Waiting 3rd digit Second digit entered Third digit entered Wrong Key Opening door Good Key Spontaneous transition

39 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

40 Unified Modeling Language 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


Download ppt "Chapter 2.1 Program Design and Documentation. Summary System/Program specifications System/Program design –Top-down & Bottom-up design –Object Oriented."

Similar presentations


Ads by Google