Object Oriented Second Blog Assignment

Object Oriented Second Blog Assignment

First, the analysis program structure

fifth assignment

measure

Class Diagram

Collaboration diagram

Bug Analysis

1. This job is output in the file for the first time, and one part is missed when it is modified, resulting in a part of the output of the file missing; 2. There are two other bugs caused by improper handling of wait and notify. code throws.

Design analysis

Because it is the first time to design a multi-threaded program, and the randomness of multi-threading will cause some boundary bugs, a lot of energy is spent on dealing with boundary problems, which greatly increases the amount of code, resulting in cluttered code logic.

sixth assignment

measure

Class Diagram

Collaboration diagram

Bug Analysis

1. Wrote a wrong function name when dealing with homogeneity. Since there was no time to check these problems in the refactoring on Tuesday night, a bug appeared; 2. The file security class was not handled properly, resulting in a small probability of reading the wrong text. file information.

Design analysis

This time, I initially wanted to scan each operation through the interaction between threads. In the end, the teaching assistant said that this could not be done. After the redesign, the various monitors were written separately to ensure that the same bugs would not be caused. This time the structure is more reasonable, but there are small mistakes.

The seventh homework

measure

Class Diagram

Collaboration diagram

Bug Analysis

1. The shortest path processing does not consider the situation where the starting point and the ending point are the same. 2. The other two input bugs where the benevolent sees benevolence and the wise see wisdom, and will not be analyzed.

Design analysis

This time, the design idea is more obvious. Although 100 threads are complicated, 100 threads are in line with the original intention of simulating reality, so I still do it. Practice has proved that it can be handled. In order to balance the functions of each class, in addition to the requestQueue class encapsulated to ensure thread safety, the part that selects the best rental is placed in the request class to ensure the workload of each class.

2. Strategies for finding bugs in others

Multi-threaded programs are not suitable for testing with a large amount of data, because even if there is a problem, it is difficult to troubleshoot where the problem lies. Submitting a bug in this way is irresponsible for the course. So I mainly did it by reading the code and found the logic error. The three assignments I got, the other side made a small mistake. There was no problem with the original design, but there was a mistake when writing. Such a bug is difficult to pass the data. to discover.

Three, multi-threaded design summary

After three multi-threaded operations, I roughly understand the principle of multi-threading. The design of multi-threading focuses on the control of mutual exclusion and synchronization. The main difference between multi-threading and single-threading is that programs are not executed sequentially, and some means are needed to meet the needs of execution. Order, when designing, mainly consider the order of execution, lock, wait, and wake up in the appropriate place. If you do this well, there is no difference between multi-threading and single-threading.

Fourth, experience

It's better to start writing code on Tuesday, anyway, sooner or later it will have to be refactored.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325120329&siteId=291194637