Second Object Oriented Blog Assignment

1. Overview

In these several assignments, our work focus has gradually shifted from the realization task to the comprehensiveness and balance of object-oriented development. Object-oriented development requires that each class be similar in size (lines of code), the code is easy to read, and the documentation is clearly visible. However, even now, there are still many details. For example, the code I read still has a lot of "\d*" in the regular expression, or someone uses Integer.phraseInt(string) to convert. The regular expression can match whether it is a number, but it cannot match whether it is a legal number (such as the super-long 2147483648). These issues are worth discussing and optimizing.

Also, in synthetic problems I still get untested code that normally doesn't work, yet the author doesn't know it. Therefore, I think that the author himself needs to debug related matters instead of waiting for points to be deducted.

Second, the object-oriented fifth job - multi-threaded elevator scheduling

I have a problem with the multithreaded elevator scheduler for the fifth job. Because time was in a hurry, I only completed the relevant structure, and submitted the job without the data to test the regular expression and the status of the simulation run. In the end it led to its own ineffective homework. I've only tested the wrong input under normal conditions, but the correct extreme input under normal conditions has not been tested.

The elevator dispatching operation this time is repeated

3. The sixth task of object-oriented - IFTTT simulation

In the sixth assignment, we implemented the file monitoring program. For each file, we need to implement recursive monitoring. In my opinion, the difficulty of monitoring is creating new files. For a new file, it is necessary to determine whether it is the renaming or change time of other files.

Checking the duplication of this newly created file involves two sets of operations. For the mutually exclusive parts of the two sets, it is necessary to determine whether there is a corresponding relationship. But this correspondence also includes changes in information such as time and name. Therefore, you cannot write only one .equals function, you need to define multiple equals functions and comparison functions to determine whether there is a corresponding relationship between the two files.

The file type is not a safe file access type. For each file object, we need to create a unique file object to prevent simultaneous read and write operations. In fact, in this process, because there are related operations between reading (monitor process) and writing (instruction process), you can actually know that this file has been occupied by your own wait method. Therefore, the so-called "two processes of reading and writing cannot communicate with each other" is actually very difficult to do.

Fourth, the object-oriented seventh operation - the first simulated taxi dispatch.

In this assignment, there is a lot of randomness. The source of randomness is the moving position of the vehicle. It can be obtained by observation that the vehicle has a high probability of going backwards.

Because of the existence of one hundred threads, the wake-up time of the vehicle is random during the actual movement of the vehicle. Therefore, the length of sleep time should not be

  Sleep(200)//The default is 200ms sleep cycle

Instead, it should be Sleep(200-(currenttimemill - previous time mill)); to ensure the time synchronization effect of multiple threads.

In addition, in this taxi pathfinding process, my pathfinding method is to build a bfs and move towards a location with a shorter path. However, in the case of future traffic jams and other situations, bfs may not be the optimal choice.

I saved the time effect of bfs. Two bfs searches are performed in a three-second time frame, so that the taxis do not need to be overly complicated wayfinding when they are running.

The bfs of the gui does not store the results of the bfs. I think this should be the result required by the subsequent operations.

Guess you like

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