Summary of the second stage of OO learning

  The second stage of the object-oriented course is over. The homework has stepped from a simple toy mode to a complex multi-threaded hell mode, and the previous simple implementation of the algorithm has a pit to a complex algorithm. There are big pits. One of the most important The experience is that you must know the implementation of the entire program before you start typing the code, and think about the functions and excuses of each module, so as to avoid changes in the later period, and even ridiculous bugs. In other words, it is to move bricks at will, to move bricks according to the blueprint, so that it is easy to find out which bricks are in the wrong place when they are still in prototype. Of course, it is necessary to test later to see which bricks will live in people. Time to drop the chain.

Fifth assignment:

Class Diagram

 

Metric Chart:

       My problem is that too many tasks are handed over to the elevator class itself. These tasks or functions should be split out and divided into other classes. The main bug is that the elevator runs between the floor and the target floor. Insert new commands in between and discard the commands that are not carried after reaching the target floor of the main command and put these commands back into the command tray. In fact, I also thought about this problem before implementing it, but I didn’t record it and forget it when I implemented it. now...

sixth assignment

Class Diagram:

Metric Chart:

The content of the sixth homework is still very clear. My problem is that I failed to separate the problem into methods or classes, and try to solve all problems in one large class or large method, such as watchThread this time, all monitoring logic I wrote it all together, and then it became red. I thought about how this kind of problem came about, and then I found that I didn't know how to pass correct information between classes, methods and methods. It seems that sharing variables directly It's not very suitable, so I had to write it in a ball... Anyway, object-oriented thinking still needs to continue to practice.

The bug is mainly caused by the conflict between the recovery and monitoring of each thread. I paid attention to what the teacher said in class. The method of the teacher to create a snapshot seems to be to create a tree-structured file system mapping for each scan, and my implementation method is to create a snapshot every time. Scanning the file system every time is complicated and time-consuming, so it is prone to bugs.

The seventh homework

Due to some reasons of my own, the seventh homework collapsed, and the final implementation was so tragic that I didn't even want to put up the class diagram and measurement results, so I simply analyzed the bug situation.

One is that you need to re-implement the method of finding the shortest path by yourself. Otherwise, the implementation of the GUI is too time-consuming, and strange phenomena will occur, especially when many taxis receive orders at the same time. The other is the processing of time, because it is obtained directly The system time is then selected, so there will be some small problems if it is not handled well in some places.

Summarize:

       With the increase of program complexity, especially the introduction of multi-threading, it becomes more and more difficult to understand a code, so the importance of documentation is getting higher and higher. Every time you must write a readme well, I got it once The readme even became garbled, which caused great difficulties for mutual testing. It is also my responsibility to write the document well. I once had a bug that I figured out and corrected in the process of writing the document.

  The security issues of multi-threading actually need to be thought carefully. Some are logically parallel, but in fact, they are processed sequentially in one thread, and some are logically and sequentially processed in parallel in different threads. As long as multiple threads are involved, you must think carefully. Thread safety. In addition, although the synchronized keyword helps to solve thread safety, it cannot be abused!

 

Guess you like

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