Pair project: Implementation and test of elevator scheduling algorithm--report

Source: Internet
Author: User

First, the programming staff

Xu Fangyu, Chen Shaojie

Second, work photos

Iii. advantages and disadvantages of pairing programming

Advantages:

1. Programmers help each other, teach each other, can get the ability to complement each other.

2. You can enable the programming environment to implement design effectively.

3. Enhance the code and product quality, and effectively reduce the bug.

4. Reduce the cost of learning. While programming, sharing knowledge and experience, effectively in the practice of learning.

5. In programming, talking to each other can solve problems faster and more effectively.

Disadvantages:

    1. For programmers who have different habits, they can get into trouble, even contradictions, in their work.
    2. Two people working together can be a situation where work energy cannot be concentrated. Programmers may talk about things unrelated to their work, instead distracting them, resulting in less efficiency than a single person.
    3. Experienced veteran may feel very irritable in the face of novice. Inappropriate communication leads to disharmony in the team.

Iv. the pros and cons of each team member

    1. Xu Fangyu: Ability to program, read and analyze code, be patient, be friendly. Sometimes attention is drawn to the game.
    2. Chen Shaojie: Get along well with teammates, careful, good programming skills. The ability to analyze code is weak.

V. Using these good design methods

1.Jnformation hiding

Information hiding is a good method of structured design and object-oriented design. Can let us call some methods, do not have to care about how the internal implementation of this method, just need to know how to use. This reduces the amount of code and makes programming difficult.

In this elevator scheduler, we can implement a function in a way that can be called where the function is needed. For example, in the passenger class to define the Enterelevator, Leaveelevator method to achieve a passenger into the elevator, leaving the elevator process, when the need to complete the process, only need to call this method, do not have to consider the way this method is implemented.

  2.Interface Design:

The interface should be in accordance with the six principles: Single duty principle, Richter replacement principle, dependency inversion principle, interface isolation principle, Dimitri rule, open and close principle.

In the elevator dispatching program, we design the Ielevator, Ipassenger and so on as the interface, after implementing this interface, the transmission data can be carried out by the data in the interface, convenient method realization.

  3. Loose coupling:

The goal of loose coupling is to minimize dependencies, i.e., between functional functions, the degree of dependency is not too high, so that the programmer does not modify a function, so that other functions along with it to modify a lot.

VI. Design by contract, Code contract

Contractual design requires software designers to define formal, accurate, and verifiable interfaces for software components, which adds a priori, posteriori, and invariant to the traditional abstract data types. It considers the relationship between the class and its client program as a formal agreement, describing the rights and obligations of both parties.

Advantages: Contract design can achieve better design, improve program reliability, help debugging, and can support multiplexing. The code contract can be designed by contract, which can significantly reduce the potential defects in the software.

Cons: Personal feelings, contractual design is not conducive to the programming process into the new idea of the programmer-after the contract is determined, it is necessary to strictly design according to requirements, even if there is a better design, can not be arbitrarily modified original design.

Vii. UML Diagram

  

Eight, the algorithm

In the preparation of this procedure, we only know the number of elevators in the ladder, the weight of the ladder as a precondition, this is in line with the actual situation.

When considering the elevator scheduling algorithm, we found such a problem: when a lot of people are in an elevator, the elevator to enter a person will spend the ladder of everyone waiting to switch the elevator door time, resulting in more time consumption, so when the elevator, we prioritize people less, weight, number of room, The direction of operation and the direction of the ladder is the same and can shun the road elevator to complete the call ladder request.

Under the way of allocation of this request, the elevator runs in the current direction of movement, only in the request of the floor and outside the ladder to stop, complete the current direction of operation of all the requests, the reverse direction to continue to complete another direction of the request.

IX. Results Analysis

The elevator scheduling program is not smooth, after writing the program, Passenger1 test successfully passed, but there is a dead cycle in Passenger2. After debugging, although the passenger2 of the dead loop, but the scheduling efficiency is very low, Then again into the Passenger3 test of the Dead loop, debugging for a long time finally jumped out again.

After analysis, we think that the cause of the program operation is not good because of the following:

    1. The scheduling algorithm is not detailed enough. May be too much attention to the elevator number of this condition, resulting in the elevator operation may sacrifice the more recent elevator choice to choose a very far elevator, and has been assigned to the fewest number of executable elevators can also cause confusion of command allocation, increase unnecessary distance.
    2. The idea and the basic frame of the elevator procedure are contradictory. In the process of writing a program, in order to meet the logic of the scheduling algorithm, we moved some of the code is located in the file, and covered a part of the original logic of the code, these practices are undoubtedly very dangerous, will add a lot of unexpected trouble.
    3. C # Lack of knowledge, the ability to read code is not enough. Ashamed to say, this is the first time we use C # to program, our understanding of C # This language is very weak, this homework need to read the code is not small, although we spent nearly two days to read the code, but still can not be understood thoroughly, Otherwise, the idea will not be inconsistent with the basic framework of the program.
    4. Code is not neat, writing habits is not good. In the process of writing, sometimes will be divided into the corresponding case of parentheses, and each line of code is not neat, to increase the difficulty of understanding, and sometimes think of a place to add logical judgments and other statements, so only temporarily in the role of the code snippet before and after the addition of the format has become more chaotic; The habit of writing multi-layered nesting also makes algorithm implementation cumbersome and error-prone.

Ten, feelings

The scheduling algorithm is written, rather than learning programming, rather than a reflection of the process. In the process of writing, I really found a lot of problems of their own, these problems have been in fact, but did not cause real trouble. When we are faced with deeper learning tasks, they limit our ability to reduce efficiency. We are very glad to find so many problems of ourselves through this homework.

Pair project: Implementation and test of elevator scheduling algorithm--report

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: info-contact@alibabacloud.com 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.