Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming.

Similar presentations


Presentation on theme: "1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming."— Presentation transcript:

1 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming

2 2 Design Terminology Large problems can be broken down into smaller problems divide-and-conquer approach called stepwise refinement Stepwise refinement is part of top- down design methodology

3 3 Top-Down Design General problems are at the top of the design Specific tasks are near the end of the design Top-down design and structured programming are techniques to enhance programmers' productivity Top-down design aided through the use of hierarchy charts

4 4 Top-Down Design Criteria 1.The design should be easily readable and emphasize small module size. 2.Modules proceed from general to specific as you read down the chart. 3.The modules, as much as possible, should be single minded. That is, they should only perform a single well-defined task. 4.Modules should be as independent of each other as possible, and any relationships among modules should be specified.

5 5 Beginning of Hierarchy Chart Start by determining the high-level tasks

6 6 Detailed Hierarchy Chart Then refine the major tasks, breaking them into subtasks.

7 7 Structured Programming Control structures in structured programming: Sequences: Statements are executed one after another. Decisions: One of two blocks of program code is executed based on a test of a condition. Loops (iteration): One or more statements are executed repeatedly as long as a specified condition is true.

8 8 Advantages of Structured Programming Goal to create correct programs that are easier to write understand m odify

9 9 Easy to Write Allows programmer to first focus on the big picture and take care of the details later Several programmers can work on the same program at the same time Code that can be used in many programs is said to be reusable

10 10 Easy to Debug Procedures can be checked individually A driver program can be set up to test modules individually before the complete program is ready. Using a driver program to test modules (or stubs) is known as stub testing.

11 11 Easy to Understand Interconnections of the procedures reveal the modular design of the program. The meaningful procedure names, along with relevant comments, identify the tasks performed by the modules. The meaningful procedure names help the programmer recall the purpose of each procedure.

12 12 Easy to Change Because a structured program is self- documenting, it can easily be deciphered by another programmer.

13 13 Object-Oriented Programming an encapsulation of data and code that operates on the data objects have properties, respond to methods, and raise events.

14 5.5 Case Study 14 Validate and input data Compute current earnings Compute total earnings to date Compute FICA tax Compute income tax withheld Compute take-home pay Display info Adjust pay by withholding allowances Withheld (single) Withheld (married) Give payroll information

15 5.5 Case Study 15

16 16 5.5 Case Study The major steps in the high-level task of displaying the payroll information are found in the event procedure.

17 17 5.5 Case Study Statements calling the procedures for Task 0 (validating and inputting data).

18 18 5.5 Case Study Statement calling the procedure for Task 1 (computing current earnings).

19 19 5.5 Case Study Statement calling the procedure for Task 2 (computing total earnings to date).

20 20 5.5 Case Study Statement calling the procedure for Task 3 (computing FICA tax).

21 21 5.5 Case Study Statement calling the procedure for Task 4 (computing income tax withheld).

22 22 5.5 Case Study Statement calling the procedure for Task 5 (computing take-home pay).

23 23 5.5 Case Study Statement calling the procedure for Task 5 (displaying information).

24 24 5.5 Case Study Procedures for Task 0 (validating and inputting data).

25 25 5.5 Case Study Procedure for Task 1 (computing current earnings).

26 26 5.5 Case Study Procedure for Task 2 (computing total earnings to date).

27 27 5.5 Case Study Procedure for Task 3 (computing FICA tax).

28 28 5.5 Case Study Procedure for Task 4 (computing income tax withheld). Task 4 involves three subtasks.

29 29 5.5 Case Study Procedures for Tasks 4.2 (single withholding) and 4.3 (married withholding).

30 30 5.5 Case Study Procedure for Task 5 (computing take-home pay).

31 31 5.5 Case Study Procedure for Task 5 (displaying information).

32 Stub Testing A stub is an empty procedure. You can create functions or procedures with mainly just the signature and a minimum bit of code Thus, the whole calling process can be tested before testing the individual modules That way, you can incrementally build the application, one module at a time. 32

33 Stub Testing 33 Here, the tasks are implemented as procedure stubs. Stubs have very little code inside, mainly just the signatures.

34 Stub Testing 34 Note: for Function stubs, you need something for a return value…here we just arbitrarily return 0. This program will compile, and you can test to ensure that the proper procedures are being called.

35 Running program outside VB.net Distribution program (not files) to others: 1 file No ability to edit Must have Microsoft’s.NET Framework Most computers have (it is free) Change icon Set startup form Choose the Debug/Build menu option.EXE file is Located in bin\Release folder 35


Download ppt "1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming."

Similar presentations


Ads by Google