How to prepare for the software exam-Software Designer (Part 2)

Foreword:

There are generally 6 questions in the afternoon. The first 4 questions are mandatory, and questions 5 and 6 are optional. Each question is worth 15 points, for a total of 75 points, and you can pass with 45 points.

Next, we will use the cases of software designers in the second half of 2022 as teaching materials to explain how to solve each type of problem in the afternoon.

1. Data flow diagram analysis

topic

【illustrate】

With the rapid growth in the number of new energy vehicles, the number of supporting charging piles for electric vehicles across the country has increased rapidly, which has also brought about problems with the accuracy of charging pile measurement. Charging piles need to be equipped with corresponding electric energy measurement and electricity billing functions, and the accuracy of charging measurement needs to be mandatory. It is now necessary to develop metrological verification cloud software, whose main functions are:

(1) Data reception. Receive charging data reported by the metering device, that is, charging monitoring data and metering data such as voltage, current, and electric energy during the charging process (charging monitoring data is the data monitored by the charging pile, metering data is the data measured by the metering device, with seconds as the interval unit) , receive the heartbeat data of the metering device and store it separately.

(2)Basic data maintenance. Administrators maintain basic data such as charging piles and metering verification devices.

(3) Data analysis. Achieve comparison of voltage, current, and electric energy data, conduct error analysis, and record the charging error of the charging pile for calibration of the metering device. The system displays the query statistical results based on the query and statistical conditions given by the measurement and testing personnel.

(4) Charging pile verification. Analyzing charging errors: Metrology and inspection personnel calibrate the charging pile based on the error analysis results and calibration information records, and submit the calibration results: the system updates the calibration information (calibration results and calibration time) in the charging pile and stores it in the calibration record.
(5) Abnormal alarm. Detect the heartbeat of the metering device and send an alarm to the administrator when the heartbeat stops.

(6) Acquisition of calibration information for other third-party services related to charging piles to query the calibration information in charging piles. A structured method is now used to analyze and design the metrology verification cloud software, and the context data flow diagram shown in Figure 1-1 and the layer 0 data flow diagram shown in Figure 1-2 are obtained.

[Question 1] (4 points)
Using words from the description, give the names of entities E1~E4 in Figure 1-1.

[Question 2] (5 points)
Using words from the description, give the names of data stores D1~D5 in Figure 1-2.

[Question 3] (4 points)
Based on the words in the description, supplement the missing data flow and its starting point and end point in Figure 1-2.

[Question 4] (2 points) According to the instructions, give the composition of the "charging monitoring and metering data" data stream.

Analysis:

Question 1 (4 points)

Question: Using words from the instructions, give names for the entities E1~E4 in Figure 1-1.

When analyzing data flow questions, first look at the common name corresponding to E in question 1, and then look back at the questions. The first two questions are generally relatively simple. For the name of E, we can go back and read the description with a few questions:

For E1, we can look it up from the description with the following questions:

1. Who reports heartbeat data?

2. Who reports the measurement data?

It is easy to getE1: Measuring device.

For E2, we can look it up from the description with the following questions:

1. Who is notified of the alarm information?

2. Who entered the basic data?

It is easy to getE2: Administrator.

For E3, we can look it up from the description with the following questions:

1. Who submits the query and statistical conditions to the system?

2. Who are the verification information records sent to?

3. Who submitted the test results?

It is easy to concludeE3: Measurement and inspection personnel.

For E4, we can look it up from the description with the following questions:

1. Who initiates the information inquiry request?

2. Who will the test information be returned to?

It is easy to getE4: Third-party service.

Question 2 (5 points)

Question: Using words from the description, give the names of data stores D1~D5 in Figure 1-2.

Question 2 is the simplest. If the input and output are the same, the table is the input quantity + table. If there is only input or only output, use input + table or output + table, and this basically means the lack of data flow.

D1 inputs charging detection and measurement data, and the output is the same, so the table must beCharging detection and measurement data table.

D2 inputs basic information and has no output, so the table must bebasic informationtable . There is a data stream output by D2 missing here.

D3 inputs the heartbeat data of the metering device and outputs the heartbeat data, then the table isheartbeat datatable.

D4 inputs charging error information and outputs charging error, so the table must becharging error table.

D5 has no input and the output is a verification record, so the table must be Verification RecordTable. There is a D5 input data stream missing here.

Question 3 (4 points)

Q: According to the words in the description, supplement the missing data flow in Figure 1-2 and its starting point and end point.

Generally speaking, Question 3 is the most difficult. To summarize here, data flow is generally the interaction between E, D and P. E and D generally do not interact directly. The next step is how to find missing data streams. There are generally three rules to share with everyone.

Rule 1: XX table, generally input and output exist in pairs. If there is a lack of input or output, it means that there is probably a missing data stream.

Rule 2: The input and output data streams in P generally exist in pairs. If there is one in the input item but not in the output item, it means that there is one less data flow.

Rule 3: P operations generally rely on data tables, such as relying on data tables for calculations and storing input data in data tables.

According to the above rule 1, it can be found that D2 has no output and D5 has no output.

So who needs basic information? We can infer that during data analysis, there is a lack ofdata flow D2->P4 and basic information.

Similarly who enters the records? We can know from the description that when the charging pile is calibrated, there is a lack ofdata stream P4->D5 and calibration record.

According to the above rule 2, it can be found that P3 has one input and two outputs, so one is missing.

Who initiated the query of statistical results? Naturally, it is a measurement and inspection personnel, so there is a lack of data flow: E3->P3, query and statistical conditions.

According to rule 3 above, it can be found that P6 has no dependencies or is stored in any data table, which is also problematic.

According to the description, it was found that the data stream is missing:D5->P6, verification record.

Of course, there must be some other data streams, but they are difficult to find, so I won’t list them all here.

【Question 4】(2 points)

According to the description, the composition of the "charging monitoring and metering data" data stream is given.

The scope of question 4 is not fixed. Generally, the scope of the question is relatively broad.

This question is very simple. From all the charging monitoring and metering data in the description, we can find the following description:

Then we can copy it directly. The answer is:

During the charging process, charging monitoring data and metering data such as voltage, current, and electric energy (charging monitoring data is the data monitored by the charging pile, metering data is the data measured by the metering device, with seconds as the interval unit), receives the heartbeat data of the metering device, and records them respectively. for storage.

2. Conceptual structure design analysis of database design

topic

[Explanation] In order to facilitate the management of branches and stores in various places, a marketing company plans to develop a business management system. Please complete the database design of the system according to the following demand description.
[Description of requirements]
(1) Branch information includes: branch number, branch name, address and phone number. Among them, the branch number uniquely determines each tuple of the branch relationship. Each branch has multiple stores, and each store belongs to only one branch.

(2) Store information includes: store number, store name, store manager, branch number, address, phone number, among which the store number uniquely determines each tuple in the store relationship. Each specialty store has only one store manager, who is responsible for all the business of the specialty store: each store manager is only responsible for one specialty store: each specialty store has multiple employees, and each employee only belongs to one specialty store.

(3) Staff information includes: staff number, staff name, store number, position, phone number, and salary. Among them, the employee number uniquely identifies each tuple in the employee relationship. Positions include store manager, salesperson, etc.
[Conceptual Model Design]
Based on the information collected in the requirements stage, the designed entity relationship diagram (incomplete) is shown in Figure 2-1.

[Logical structure design]

Based on the entity contact diagram completed in the conceptual model design stage, the following relationship model (incomplete) is obtained: Branch (branch number, branch name, address, phone number) Store (store number, store name, ___(a) __, staff, address, phone number) Staff (staff number, staff name, ____(b)___, position, phone number, salary)

[Question 1] (6 points)
According to the requirement description, three connections are missing in the entity relationship diagram in Figure 2-1. Please add three connections and contact types in the entity connection diagram corresponding to the answer sheet.
Note: The contact name can be Contact 1, Contact 2, Contact 3: You can also choose the contact name based on your understanding of the meaning of the question.

【Question 2】(6 points)

(1) Complete the attributes of ____(a)___ and ____(b)___ in the relational formula and fill in the corresponding positions on the answer sheet.
(2) The primary key of the store relationship: ____(c)___ and the foreign key: ____(d)___.
The primary key of the employee relationship: ____(e)___ and the foreign key: ____(f)___.

【Question 3】(3 points)

In order to contact the family members of employees in time when an emergency occurs, the store requires each employee to fill in at least the name, relationship and contact number of the emergency contact person. Based on this situation, the entity ___(g)___ needs to be accessed in use 2-1, and the relationship type between the employee relationship and this entity is ____(h)___.
(3) Give the relationship model of the entity.

Analysis:

【Question 1】(6 points)

According to the requirement description, three relationships are missing in the entity relationship diagram in Figure 2-1. Please add three connections and contact types in the entity connection diagram corresponding to the answer sheet.
Note: The contact name can be Contact 1, Contact 2, Contact 3: You can also choose the contact name based on your understanding of the meaning of the question.

To find the relationship, you must read the requirement description carefully, and then look for the relationship from the requirement description. Pay special attention to the many-to-many correspondence, such as in the description:

According to the description, there are a total of 3 relationships:

The relationship between branches and specialty stores, branch 1: specialty store N;

The relationship between specialty stores and store managers, specialty store 1: store manager 1;

The relationship between specialty stores and staff, specialty store 1: clerk N.

【Question 2】(6 points)

(1) Complete the attributes of ____(a)___ and ____(b)___ in the relational formula and fill in the corresponding positions on the answer sheet.
(2) The primary key of the store relationship: ____(c)___ and the foreign key: ____(d)___.
The primary key of the employee relationship: ____(e)___ and the foreign key: ____(f)___.

a and b are searched directly from the description and the answer is easily obtained.

a is: store manager, branch number

b is: store number

In the store information, the primary key determines the unique relationship. To see if the uniqueness can be determined through the primary key, the store number is the primary key, c: store number.

Foreign keys are related to information in other tables. See which fields can be related to other tables. Then the store manager and branch number can be associated with other tables, which is a foreign key, d: store manager, branch number.

Similarly, the primary key of the employee relationship is the employee number, e: employee number. Foreign key store number, f: store number.

【Question 3】(3 points)

In order to contact the family members of employees in a timely manner in the event of an emergency, the store requires each employee to fill in at least the name, relationship and contact number of an emergency contact person. In this case, you need to add the entity ___(g)___ in 2-1. The contact type between the employee relationship and this entity is ____(h)___.
(3) Give the relationship model of the entity.

Add entity: g: emergency contact;

Fill in at least 1 emergency contact person, which is N. So Staff 1: Emergency Contact N.

Relationship model:

Emergency contact person (emergency contact number, employee number, emergency contact name, relationship with the person, contact number)

3. Object-oriented class diagram design

topic

[Explanation]
Figure 3-1 shows the interface of a temperature control module in a software system. Two temperature measurement units are provided on the interface, namely Fahrenheit (Farechet) and Celsius (Celsius). The software supports automatic conversion between two measurement units, that is, if you enter a temperature in Fahrenheit, its corresponding temperature value in Celsius will automatically appear in the Celsius display box, and vice versa. The user can change the temperature value through the buttons Raise (increase the temperature) and Lower (lower the temperature) on the interface. On the right side of the interface is a thermometer, which converts the temperature in digital form into a system ratio on the thermometer for display. When the temperature value changes, the thermometer's display also changes synchronously.

Now use the object-oriented method to implement the temperature control template, and obtain the use case diagram shown in Figure 3-2 and the class diagram shown in 3-3.

[Question 1] (4 points)
According to the description in the instructions, give the use case names corresponding to U1~U4 in Figure 3.2.

[Question 2] (8 points)
According to the description in the instructions, give the class names corresponding to C1~C8 in Figure 3-3 (the class names use Figure 3- Vocabulary marked in 1).

[Question 3] (3 points)
The interface shown in Figure 3-1 now needs to be transformed into a more general GUI application that can implement any measurement unit. Conversions, such as the conversion between kilograms and centimeters, centimeters and inches, etc. In order to realize this new requirement, which design pattern can be added to the class diagram shown in Figure 3-3? Please explain the reason for choosing this design pattern (no more than 50 words).

Analysis:

【Question 1】(4 points)

Here we first look at the display of Celsius under U2, which corresponds to the display of Fahrenheit, so U2 is Display Fahrenheit. Because U1 isdisplaying temperature. It can be known from the description that there are three types of displayed temperatures, so U3 is the thermometer display. In addition to displaying temperature, U1 and U2 have another common point in common, which is mutual conversion, so U4 is automatic conversion.

name Use case name
U1 Display temperature
U2 Show Fahrenheit
U3 Thermometer display
U4 automatic conversion

【Question 2】(8 points)

First see Button, which belongs to Widget and is at the same level as C2, C3, and C4. Then C2 to C4 must also belong to Widgets. As you can see from the picture, in addition to the buttons, there are also the thermometer's Bar, the edit box EditBox, and the description Text above the edit box.

Then, we see that C5 to C8 all belong to the extended type of Button, so just look for how many types of Button there are in the corresponding figure. RahrenheiRaise, RahrenheiLower, CelsiusRaise, CelsiusLower.

After identifying C2 to C8, we found that they all point to C1, so only TemperatureCovertorDialog can load all Widgets to create associations.

parameter name Class name
C1 TemperatureCovertorDialog
C2 Bar
C3 EditBox
C4 Text
C5 RahrenheiRaise
C6 RahrenheiLower
C7 CelsiusRaise
C8 CelsiusLower

【Question 3】(3 points)

This question is more professional, and students who are not familiar with design patterns can give up strategically.

But if you do too many soft exam questions, you can know that this belongs to the strategic mode. There is nothing to talk about, and it mainly relies on accumulation.

Strategy Pattern belongs to the behavior pattern of objects. Its purpose is to encapsulate each algorithm into an independent class with a common interface for a set of algorithms, so that they can be replaced with each other. The strategy pattern allows the algorithm to change without affecting the client.

4. Algorithm fill-in-the-blank questions

topic

Read the following instructions and C code, answer questions 1 to 3, and fill in the answers in the corresponding columns on the answer sheet.
[Explanation] Question sorting is the process of adjusting a set of unordered data elements into a non-decreasing sequence of data. Heap sorting is a commonly used sorting algorithm. Use a sequential storage structure to store elements in the heap. The steps of non-decreasing heap sorting are:
(1) Construct an initial large top heap containing n elements to be sorted, and store it in the array R(R[1], R[2 ],..., R[n]). At this time, the size of the heap is n, the top element R[1] of the heap is the largest element in the sequence, and R[n] is the last element in the heap.
(2) Exchange the top element of the heap with the last element in the heap, the last element is separated from the heap structure, the size of the heap is reduced by 1, and the remaining elements in the heap are adjusted into a large top heap; ( 3) Repeat step (2) until only the last element is left in the heap structure. At this time, the array R is a non-decreasing data sequence.
[C code]
The following is the C language implementation of this algorithm.
(1) Main variable description
n: length of array to be sorted
R[]: array to be sorted, n The numbers are placed in R[1], R[2],..., R[n]
(2) Code

#include <stdio.h>
#define MAXITEM 100
/**
调整堆
R:待排序数组:
v:节点编号,以v为根的二叉树,R[v]≥R[2v],R[v]≥R[2v+1],且其左子树和右广树都是大顶堆:
n; 堆结构的规模,即堆中的元素数
*/
void Heapify(int R[MAXITEM], int v, int n)
{
    int i, j;
    i = v;
    j = 2 * i;
    R[0] = R[i];
    while (i <= n)
    {
        if (j < n && R[j] < R[j + 1])
        {
            j++;
        }
        if ((1))
        {
            R[i] = R[j];
            i = j;
            j = 2 * i;
        }
        else
        {
            j = n + 1;
        }
    }
    R[i] = R[0];
}

/*堆挂序,R为待排序数组:n为数组大小*/
void HeapSort(int R[MAXITEM], int n)
{
    int i;
    for (i = n / 2; i >= 1; i--)
    {
        // (2)
    }
    for (i = n; (3); i--)
    {
        R[0] = R[i];
        R[i] = R[1];
        // (4)
        Heapify(R, 1, i - 1);
    }
}

[Question 1] (8 points)
According to the above instructions and C code, fill in the empty spaces (1)~(4) in the C code.

[Question 2] (2 points)
According to the above explanation and C code, the time complexity of the algorithm is (5) (expressed in O notation).

[Question 3] (5 points)
Consider the data sequence R=(7, 10, 13, 15, 4, 20, 19, 8), n=8, then The initial big top heap constructed is (6), the first element is separated from the heap structure, and the remaining elements are adjusted into the big top heap, and the array R after the big top heap is (7).

Analysis:

Algorithm questions are often the most difficult of the afternoon questions. Sometimes it is even difficult for us to describe them in detail and understand what the question maker wants to express. But in the process of doing the questions, there are often some tips. Let's take this question as an example. We don't understand how it is implemented or what a big top heap is, but try to answer this question.

【Question 1】(8 points)

First, let's analyze the code. HeapSort should be a sorting method and it calls Heapify, so Heapify should be a certain sorting. When sorting, it is Heapify(R, 1, i - 1); starting from 1, 0 is not used, so R[0] should be the location used for data exchange.

Let’s skip (1) and look at (2) first. (2) There is only one line, so it should be data assignment or method call. But there are constant i-- for sorting below, so there should be no assignment involved, so it should be an initialization type of operation. How to initialize it? It must be done through several sortings, so the Heapify method must be called here, and then there is the issue of parameters. Refer to the Heapify call below. The first parameter is R, and the second parameter should be i. Because the loop here is constantly moving forward, we only need to ensure that i to N are sorted every time we sort. So(2):Heapify(R, i, n);

Looking at (3), i=n, ​​i--, then (3) is the end judgment condition, so (3) should be i>X. So what should X be? Naturally, there is no need to sort when there is only one left, so here is (3):i>=1.

Looking at (4), above R[0] = R[i]; and R[i] = R[1]; so there should be a data exchange here. Combined with the above mentioned R[0] is used to temporarily store data, then R[0] must be assigned to a certain position in the end, combined with R[i]=R[1], the first bit is assigned, so Here is (4):R[1]=R[0].

Looking back at (1), if you want to answer this question, you need to have a certain understanding of the big top pile. The Heapify method is actually building a large top heap. (1) is a conditional judgment, combined with the following assignment, so it should be a judgment like R[i]>R[j] or R[j]>R[i]. For a large top heap, we think that the larger value is on top, in other words, at the front, so if it needs to be exchanged, it should be the larger value that needs to be assigned and exchanged later. So here it should be (1): R[j]>R[i].

The above answer is my guess without understanding push sort and big top heap. The final answer may not be completely correct.

【Question 2】(2 points)

Looking at the code for algorithm complexity, HeapSort performs an N-level loop, so it is at least N here. Then look at the Heapify method. There is a while loop in it, but the progress of j=2*i is forward, so the complexity should be logN.

Because the result isO(N*logN).

【Question 3】(5 points)

If you don’t know how to heap sort this problem, there’s really nothing you can do about it.

(6):20,15,19,10,4,13,7,8

(7):19,15,13,10,4,8,7,20

5. Object-oriented programming

topic

Read the following instructions and Java code, and write the words that should be filled in at (n) in the corresponding columns of the answer sheet.
[Description]

Facade pattern is a pattern that makes multiple complex subsystems more accessible by providing a consistent interface for these subsystems. Taking a hospital as an example, when seeking medical treatment, patients need to interact with different functional departments of the hospital to complete operations such as registration, outpatient service, and medicine collection. In order to simplify the medical treatment process, a receptionist position is set up to complete the above medical treatment steps on behalf of the patient, and the patient only needs to interact with the receptionist. As shown in 5-1, the class diagram for implementing this scenario in appearance mode is given.

【Code】

import java.util.*;

interface Patient {
    ___(1)___;
}

interface Disposer {
    ___(2)___;
}

class Registry implements Disposer {
    public void dispose(Patient patient) {
        System.out.println("I am registering..." + patient.getName());
    }
}

class Doctor implements Disposer {
    public void dispose(Patient patient) {
        System.out.println("I am diagnosing..." + patient.getName());
    }
}

class Pharmacy implements Disposer {
    public void dispose(Patient patient) {
        System.out.println("I am giving medicine..." + patient.getName());
    }
}

class Facade {
    private Patient patient;

    public Facade(Patient patient) {
        this.patient = patient;
    }

    public void dispose() {
        Registry registry = new Registry();
        Doctor doctor = new Doctor();
        Pharmacy ph = new Pharmacy();

        registry.dispose(patient);
        doctor.dispose(patient);
        ph.dispose(patient);
    }
}

class ConcretePatient implements Patient {
    private String name;
    public ConcretePatient(String name){this.name =name;}
    public String getName() {return name};

}

class FacadeTest {
    public static void main(String[] args) {
        Patient patient = ___(3)___;
        ___(4)___ f = ___(5)___;
        ___(6)___;
    }
}

【Question 1】(15 points)

(1):
(2):
(3):
(4):
(5):
(6):

Analysis:

This question tests the basic skills of Java or C++, but in fact, even if you don't have the basic skills of these two languages, you can get a general understanding as long as you know a few keywords.

We first understand two keywords: extends and implements. Implements implements the interface, while extends implements the abstract class.

The interface class Patient is defined in the above code, so (1) must be the method defined by this interface. So we directly looked for its implementation class, and found ConcretePatient. This class implements the method getName(), so (1) is: public String getName();. (2) has similar logic. If we find its implementation class Registry or Docter, we can know (2):public void dispose(Patient patient)< /span>;

(3) defines the object and initializes the class, but Patient is an interface and cannot be initialized, so the initialization must be its implementation class, then Patient patient = ___new ConcretePatient(" ;")___;//Pay attention to the input parameters of the construction method here.

(4)(5) also defines the object and initializes the class, and uses the lowercase letter f to define the variable. Then the class name should start with F, and the Facade will be naturally found. So (4)(5):Facade f = new Facade(patient);

(6) Although nothing is defined, combined with the above two objects and the method definitions in Facade, we can also infer that(6):f.dispose() ;

Guess you like

Origin blog.csdn.net/AA5279AA/article/details/134396931