[Software Engineering General Review] Chapter 6 Detailed Design

Table of contents


The goal of detailed design is not only to realize the function of each module logically and correctly, but more importantly, the designed processing process should be as concise and understandable as possible.

1. Process Design Tool

1.1 Graphical tools (required)

1.1.1 Program flow chart

1.1.2 Structured flowchart NS diagram (box diagram) (emphasis) (drawing - modeling)

Loop means loop, don't use select

1.1.2.1 Definition of NS graph

NS plots are also known as box plots or NS plots. It is a kind of visual modeling in structured programming. (Nassi and Shneiderman proposed a graphical description tool that conforms to the principles of structured programming, called box diagrams, also known as NS diagrams (composed of the first letters of two people's names). In NS diagrams, all algorithms Written in a large block diagram, this large block diagram is composed of several small basic block diagrams, which can represent three basic control structures of sequence, selection and loop,)

1.1.2.2 Characteristics of NS diagram

  1. The NS diagram is intuitive, with clear functional domains and good visibility;
  2. Easily scope local and global data;
  3. Impossibility of arbitrary transfer of control;
  4. It is easy to express the nesting relationship and the hierarchical relationship of modules;
  5. The complexity is close to the code itself, and modification requires redrawing the entire graph;
  6. It forces the designer to think and describe his scheme according to the SP method, because it does not provide other description means except for the symbols representing several standard structures, which effectively guarantees the quality of the design and thus the program the quality of.

1.1.2.3 NS graphical structure (basic symbols)

1.1.2.3.1 Sequence structure

All statements are executed sequentially
insert image description here
insert image description here

1.1.2.3.2 Select structure
1.1.2.3.2.1 Conditional structure

If P is true, execute A, and if not, execute B
insert image description here
insert image description here

1.1.2.3.2.2 Multi-branch selection structure

When P=1, execute A1; when P=2, execute A2, and so on;
insert image description here

1.1.2.3.3 Loop structure
1.1.2.3.3.1 When loop structure

Execute after judgment. When the P1 condition is met, execute the A statement repeatedly until the P1 condition is not met.
insert image description here

1.1.2.3.3.1 Until loop structure

Execute first and then judge. When the P1 condition is not satisfied, execute the A statement repeatedly until the P1 condition is satisfied.

insert image description here

1.1.2.4 Examples of NS graphs

1.1.2.4.1 Example 1: Input the lengths of the three sides of a triangle, and determine whether the three times constitute an equilateral, isosceles, or general triangle

insert image description here

insert image description here

1.1.2.4.2 Example 2: Find the product of multiplying all integers from 1 to 5

insert image description here

1.1.2.4.3 Example 3: Please design a program to calculate the factorial of 5 using the NS diagram.

insert image description here
insert image description here

1.1.2.4.4 Example 4: Find the sum of all integers from 1 to 100

insert image description here

insert image description here
insert image description here

1.1.2.4.5 Example 5

insert image description here
insert image description here
insert image description here

1.1.2.4.6 Example 6

insert image description here

insert image description here
insert image description here

1.1.2.4.7 Example 7

insert image description here
insert image description here

1.1.2.4.8 Example 8

insert image description here
insert image description here
insert image description here

1.1.2.4.9 Example 9 Find the sum of 1+2+3+…+100

1.1.3 Problem analysis diagram PAD diagram (focus) (drawing - modeling)

insert image description here

1.2 Form tools (required)

Decision tables and decision trees are list design tools, which are often used in the analysis and design of complex decision situations with nested conditions, as well as the design and implementation of multi-branch structure codes.

1.2.1 Judgment table (required) (important)

(In the form of a table, multiple conditions are combined, and the relationship between the input and output results of multiple conditions can be considered comprehensively through the decision table) Judgments are used to describe things that are not easy to express clearly in language or require a lot of space to express in language Clear processing logic. In some data processing problems, the processing of its data flow diagram needs to depend on the values ​​of multiple logical conditions. The combination of these values ​​may constitute a variety of different situations, and correspondingly different actions need to be executed. It is inconvenient to describe this kind of problem in structured language, and it is most appropriate to use a decision table or a decision tree as a tool for expressing processing instructions. A decision table consists of four parts,

Condition refers to (Condition box) Combination of various conditions (condition combination)
All actions (action box) Under the corresponding combination of conditions, whether an operation should be executed (operation performed)

1.2.1.1 Judgment table case (detailed problem-solving ideas)

[Case]: Mobile phone call
1) Conditions:

Are you in arrears whether to boot
in arrears start up
no arrears not booting

2) Condition combination:

Condition 1: Whether you are in arrears Condition 2: whether to shut down result
in arrears shutdown can't talk
in arrears start up can't talk
no arrears shutdown can't talk
no arrears start up able to talk

3) Concept

Condition stub, action stub, condition item, action item

Condition pile: all possible conditions, for example, in the above example, there are two conditions: whether or not to be in arrears, whether to start the
action pile: all possible values, for example, in the above example, there are four values: arrears, no arrears , power on, not power on
Condition item: This is one or more values ​​in the condition pile
Action item: This is one or more values ​​in the action pile

4) Equivalence classes
are valid and invalid

In the judgment table, there are two ways to indicate valid and invalid.
Way 1: Expressed by letters
Valid equivalence class: Y
Invalid equivalence class: N
Mode 2: Expressed by numbers
Valid equivalence class: 1
Invalid equivalence class: 0

5) Steps to design test cases based on the decision table

The first step: first determine the condition pile

Whether it is in
arrears or
not, whether it is powered on or not. There are two conditions here, so write two lines in the table, and each line represents a condition

Step 2: Determine the Action Pile

There are four actions in total, there are 2 in each conditional pile, and there are four actions in total:
arrears, no arrears, power on
, power off

Step 3: Determine the result of the combination of conditions

Combines every value of each condition with every value of another condition

Step 4: Determine the result of the combination of conditions

insert image description here

Step 5: Write test cases based on the results

Thinking: What is the relationship between the number of conditions and the number of test cases?
The more conditions, the more the number of test cases obtained. The multiplication of
the number of conditions is equal to the number of test cases

1.2.2 Decision tree (to be tested) - simple

The decision tree is a tree graphical way to represent the actions that should be taken for multiple conditions and multiple values. The branches of the decision tree represent various conditions. With the expansion of the branch hierarchy, each condition completes its own value. The leaves of the decision tree give the actions that should be done.

1.2.3 Application of decision table and decision tree

1.2.3.1 Refine the reward conditions for student performance: the ratio of students' grades for the courses they have taken in each semester. The excellent rate accounts for more than 70%, and the proportion of below average is less than 15%, and the students with excellent performance can get the first-class scholarship, and the students with average performance can get the second-class scholarship; the excellent rate accounts for more than 50%, and the proportion of below-average Less than 20%, students with excellent performance can get the second-class scholarship, students with average performance can get the third-class scholarship; the proportion of below 20% is less than 20%, students with excellent performance can get the third-class scholarship, and students with average performance can get the fourth-class scholarship Waiting for scholarships. Please use the decision table and decision tree to express the above calculation scheme.

insert image description here

insert image description here

insert image description here

1.2.3.2 The calculation plan of a certain school’s teaching remuneration is as follows: (l) The basic teaching remuneration is 10 yuan per class; (2) If the class size exceeds 40 students, the teaching remuneration will increase: basic teaching remuneration × 0.1; (3) If the class If the number of people exceeds 60, the remuneration will be increased: basic remuneration × 0.2; (4) If the teacher is an associate professor, the remuneration will be increased: basic remuneration × 0.1; (5) If the teacher is a professor, the remuneration will be increased: basic remuneration × 0.2 ; (6) Lecturers, no increase in class remuneration; (7) Teaching assistants, less class remuneration: basic class remuneration × 0.1. Please use judgment to express the above calculation scheme.

insert image description here

1.2.3.3 The primary selection method of the postgraduate admissions system of a certain university is as follows: the total score of 300 (inclusive) or above will be entered into the candidate pool, otherwise, the math score of the withdrawn file will not be less than 70 points, then it will be entered into the third-level candidate pool, otherwise it will be entered into the fourth-level candidate pool Selection library: On the basis of the third-level candidate library, if the professional course score is higher than 100, it will enter the first-level candidate library, otherwise it will enter the second-level candidate library. Please draw the corresponding judgment table and decision tree.

insert image description here

1.2.3.4 Use the decision table and decision tree to describe the processing logic of checking the order list: "If the amount exceeds 1,000 yuan but has not expired, issue an approval note and bill of lading. If the amount exceeds 2,000 yuan but has expired, no approval will be issued Bill of lading and bill of lading. If the amount is less than 2,000 yuan, no matter whether it is expired or not, an approval note and bill of lading will be issued, and a notice must be issued if the amount is less than 2,000 yuan and has expired.

insert image description here

1.2.3.5 A certain factory has a policy of reassigning some employees to work: Those who are under 20 years old should study part-time with a junior high school education. Those with a high school education can work as electricians; those aged between 20 and 40, men with a middle school education can work as fitters, women can work as lathe workers, and those with a university education can all work as technicians. Those over the age of 40 should be employed as material workers with a middle school education and as technicians with a university education. Please use the decision table and decision tree to describe the processing logic of the above problem.

insert image description here

1.3 Language tools

1.3.1 Process Design Language PDL

2. Quantitative measure of program complexity

  1. The number of linearly independent regions in a flow graph is equal to the cyclomatic complexity
  2. The circular complexity V(G) of flow graph G = E - N + 2, where E is the number of edges in the flow graph and N is the number of nodes.
  3. The circular complexity V(G) of the flow graph G = P + 1, where P is the number of decision nodes in the flow graph.

Guess you like

Origin blog.csdn.net/weixin_51911075/article/details/128858144