Pair work Pair Programming (Zhang Yiyang)

Source: Internet
Author: User

1. Pair programmers:

   Zhang Yi (last three digits: 185) Yang Yi (last three digits: 151)

2. How we work: (picture)

Iii. Advantages and Disadvantages of Pair programming:


 1. Close Pair programming time, to a certain extent, can urge both parties to learn, improve efficiency.

2. coder will encounter some minor problems in the coding process, and reviewer can promptly point out the errors and discuss the solutions.

3. When there is a problem, the two people discuss it together and supplement what the other party did not expect. This is the best way to improve the program.


In the programming process, coder thought about the idea in the coding process for a long time. This is probably the characteristic of every programmer. At this time, reviewer will encounter a short schedule for a long time.

Iv. Advantages and disadvantages of the team members:

1. Zhang Yi:Strong programming ability, clear thinking, and practical ability. But it is very easy to be taken by anime.

2. Yang Yi:Good learning attitude, patience, and concentration. Weak hands-on capabilities.

5. Describe how to use a good design method:

    1. Information Hiding:Information Hiding is the foundation of structured design and object-oriented design. The concepts of functions and object-oriented encapsulation in the structure are derived from information hiding. The software industry has recognized this principle for the past decade.
The following lists some information hiding principles.
(1) layer and layer are added to the interface layer;
(2) All classes and classes are accessed through interface classes;
(3) All data members of the class are private, and all accesses are implemented through the access function;

The Information Hiding mechanism is very necessary in this programming job. Passengers only need to know the meaning of the button outside the elevator when taking the elevator, and the operation mechanism of the elevator does not need to be known to passengers. The program uses the private keyword to encapsulate classes.

2. Interface Design:Interfaces have seven features: stability, usability, standardization, portability, robustness, security, and compatibility. stability and ease of use are the most basic features in interface design. The interface must be relatively stable. Otherwise, the user and provider of the interface constantly modify the implementation of the interface to adapt to the new interface, it may be useless again, seriously affecting the overall software development progress.

3. Loose coupling:Coupling refers to the degree of mutual dependency between components (functions), while loose coupling refers to the degree of dependency between functional functions as much as possible. Otherwise, after modifying an underlying function, a large number of tests will be performed on multiple upper-layer functions.

Vi. Design by contract:Contractual design requires software designers to define formal, accurate, and verifiable interfaces for software components. In this way, a prior condition, posterior condition, and non-Variant Form are added for traditional abstract data types. The "contract" or "contract" used in the name of this method is a metaphor because it is similar to the commercial contract. The core idea of contractual design is to compare the elements in the software system with each other and the "responsibility" and "obligation. This metaphor comes from a "contract" between "customer" and "supplier" in a business activity.

VII. unit test:

The following is a unit test (partial) written for the scheduler class. from the right side, we can see that all the methods have passed the test:

The code coverage of unit tests is as follows:

It can be seen that unit testing has a low coverage rate for the entire program, but because we are testing the scheduler class, we should open scheduler. DLL to see the coverage of the class in unit testing:

It can be seen that the coverage rate has reached more than 80%.

8. UML diagram: (vs generation)

9. Key and uniqueness of algorithms: (source code)

There is a premise for the implementation of this algorithm, that is, passengers are more witty and will not enter the elevator that cannot reach their target when they enter the elevator.
Before implementing the algorithm, you must set a task list for each elevator and a total task list for the scheduler. API divides requests into two types: directionreq and destinationreq.
The algorithm is implemented as follows:
1. Generate a request for a request that meets the condition (the request time is consistent with the current time) and add it to the scheduler's task list.
2. Each tick scheduler is scheduled in the following two steps:
(1). Arrange the elevator for the direction request. Select an elevator that can reach the requested source floor and is closest to the source floor and is in the direction of the road or halted and has not been rejected by a passenger. The task list of the request to enter the elevator is as follows. Mark the request as allocated in the scheduler's task list.
(2). Sort the task list of each Elevator according to the operation direction of the elevator. The task list is sorted from small to large if the elevator goes up, and from large to small if the elevator goes down. Delete the request from the target layer. Check the elevator task table. If it is empty, the elevator is no longer running. Set the elevator to shut down. Otherwise, set the historical direction of the elevator and use the target floor of the first task in the task table as the next elevator stop location.

Passenger selection policy:
1. Passengers cannot enter the elevator due to two possible reasons:
(1). overweight or exceeding the number of people. In this case, the scheduler is notified to reactivate the task in the task list so that it can be rescheduled.
(2) The elevator cannot reach the specified floor of the passenger. In this case, add the elevator to the passenger's rejection list and reactivate the task in the task list so that it can be rescheduled.
2. If a passenger enters the elevator, the elevator will surely deliver the passenger. The request in the scheduler will be deleted.
3. The departure of a passenger from the elevator is the same as that of the original API and will not be changed.

The uniqueness of the algorithm lies in the consideration of the routing strategy and the best effort to schedule the elevator close to the passengers when arranging the elevator. If the elevator cannot carry a passenger to the desired destination, the request is rejected and the elevator will not be arranged for the passenger in the future.
And then schedule other elevators, which is close to real life.
In the algorithm optimization phase, we consider increasing the wisdom of passengers so that they can change their destination based on the current elevator and set the temporary destination to the farthest floor that the elevator can carry. Then switch to another elevator to improve the utilization rate of the elevator.
Unfortunately, due to time constraints, this optimization algorithm did not pass all test examples.

10. Feelings:This is my first pair of programming, and the overall feeling is very bad and painful. Although it is a Pair programming, the code is basically written by myself = 0 = I do not feel very comfortable with the pair programming mode. We read the code separately in the early stage, I always felt that I could not read the code when I was reading it with a person (however, even though I was reading it by myself, my reading process was still quite painful ). When we finished reading the code and started to discuss it, I found that my teammates were not familiar with the code, but the time was not delayed, so we entered the algorithm design stage. Originally, I wanted my teammates to design a general algorithm. I supplemented and encoded the algorithm, but it was difficult for my teammates to abstract the algorithm from natural language to program steps. So I designed a basic algorithm and encoded it. In this process, we tried to exchange work between two people, but soon I found a Data Structure usage error, it was too slow to guide my teammates. After the algorithm is implemented, the debugging phase is in progress, and the teammates are unable to get involved (because although she understands the general algorithm IDEA, she cannot fully understand the implementation of the idea in the Code ). Although I also tried to arrange debugging and some small jobs for my teammates, I couldn't wait until my teammates finish.

Conclusion: The programming level of Pair programming cannot be too different. For students with poor programming skills, another person may put pressure on her, causing her to be ashamed of programming. On the other hand, it will produce dependence on teammates, resulting in lack of self-confidence. For those with strong programming skills, the process of keeping up with the train of thought by teammates is also very painful. However, due to limited time, it is not a waste of time to familiarize other students with it, in the end, we can only turn into individualism based on the principle of "more capable. Although one person can complete the work of two people in the end, the process is not only painful, and the quality of both the Code and algorithm is not as good as the result of the cooperation between the two.

Finally, we need to talk about the lack of Pair programming when there is a big difference between the two levels. It's just that the person who needs to be weak is diligent enough to start and get familiar with the work earlier, and the time requirement of the project is not urgent. The person with strong skills can guide and help the person who is weak. In this mode, both personnel can be improved at the same time.

Pair work Pair Programming (Zhang Yiyang)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.