1 5.4 modular design top-down design structured programming advantages of structured programming
TRANSCRIPT
![Page 1: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/1.jpg)
1
5.4 Modular Design
• Top-Down Design
• Structured Programming
• Advantages of Structured Programming
![Page 2: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/2.jpg)
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
![Page 3: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/3.jpg)
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
![Page 4: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/4.jpg)
4
Top-Down Design Criteria1. 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.
![Page 5: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/5.jpg)
5
Beginning of Hierarchy Chart
Start by determining the high-level tasks
![Page 6: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/6.jpg)
6
Detailed Hierarchy Chart
Then refine the major tasks, breaking them
into subtasks.
![Page 7: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/7.jpg)
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.
![Page 8: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/8.jpg)
8
Advantages of Structured Programming
Goal to create correct programs that are easier to
• write
• understand• modify
![Page 9: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/9.jpg)
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
![Page 10: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/10.jpg)
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.
![Page 11: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/11.jpg)
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.
![Page 12: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/12.jpg)
12
Easy to Change
• Because a structured program is self-documenting, it can easily be deciphered by another programmer.
![Page 13: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/13.jpg)
13
Object-Oriented Programming
• an encapsulation of data and code that operates on the data
• objects have properties, respond to methods, and raise events.
![Page 14: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/14.jpg)
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
![Page 15: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/15.jpg)
5.5 Case Study
15
![Page 16: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/16.jpg)
16
5.5 Case Study
The major steps in the high-level
task of displaying the payroll information are found in
the event procedure.
![Page 17: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/17.jpg)
17
5.5 Case Study
Statements calling the
procedures for Task 0 (validating
and inputting
data).
![Page 18: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/18.jpg)
18
5.5 Case Study
Statement calling the procedure for Task 1 (computing
current earnings).
![Page 19: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/19.jpg)
19
5.5 Case Study
Statement calling the procedure for Task 2 (computing
total earnings to
date).
![Page 20: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/20.jpg)
20
5.5 Case Study
Statement calling the procedure for Task 3 (computing FICA tax).
![Page 21: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/21.jpg)
21
5.5 Case Study
Statement calling the procedure for Task 4 (computing income tax withheld).
![Page 22: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/22.jpg)
22
5.5 Case Study
Statement calling the procedure for Task 5 (computing take-home
pay).
![Page 23: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/23.jpg)
23
5.5 Case Study
Statement calling the procedure for Task 5 (displaying
information).
![Page 24: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/24.jpg)
24
5.5 Case Study
Procedures for Task 0 (validating
and inputting
data).
![Page 25: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/25.jpg)
25
5.5 Case Study
Procedure for Task 1 (computing
current earnings).
![Page 26: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/26.jpg)
26
5.5 Case Study
Procedure for Task 2 (computing
total earnings to
date).
![Page 27: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/27.jpg)
27
5.5 Case Study
Procedure for Task 3 (computing FICA tax).
![Page 28: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/28.jpg)
28
5.5 Case Study
Procedure for Task 4 (computing income tax withheld).
Task 4 involves
three subtasks.
![Page 29: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/29.jpg)
29
5.5 Case Study
Procedures for Tasks 4.2 (single withholding) and 4.3 (married withholding).
![Page 30: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/30.jpg)
30
5.5 Case Study
Procedure for Task 5 (computing take-home
pay).
![Page 31: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/31.jpg)
31
5.5 Case Study
Procedure for Task 5 (displaying
information).
![Page 32: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/32.jpg)
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
![Page 33: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/33.jpg)
Stub Testing
33
Here, the tasks are
implemented as procedure
stubs.
Stubs have very little code inside, mainly
just the signatures.
![Page 34: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/34.jpg)
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.
![Page 35: 1 5.4 Modular Design Top-Down Design Structured Programming Advantages of Structured Programming](https://reader036.vdocument.in/reader036/viewer/2022081511/56649f585503460f94c7de39/html5/thumbnails/35.jpg)
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