Pairing project: Elevator

Source: Internet
Author: User

Pair programming:

Advantages and disadvantages of Pair programming:

Advantages:

1. mutual supervision and joint efforts to achieve the goal;

2. Saves time. By solving and discussing difficult issues separately, we can achieve more efficient time utilization;

3. complementary capabilities to improve the quality of the Code. At the same time, it also improves the efficiency of the test code and makes it easy to give full play to the advantages of everyone;

Disadvantages:

1. mutual dependency may be formed, waiting for the other party to take the initiative, and it is easy to drag the time to the end;

2. For people with different ways of thinking and behavioral habits, there may often be some obstacles during communication, or even some small conflicts, and the efficiency of code writing may be lower than that of individual;

3. If both parties do not have strong programming capabilities, it may be difficult to form a complementary true sense;

 

Advantages and disadvantages of paired partners:

Huang jingbo is very active in thinking and has strong comprehension and programming skills, but is a little delayed;

Huang weilong has a weak foundation and is diligent, but his thinking is not flexible and his understanding is slow;

Cooperation Process:

1. read and understand the code together, find the focus, and everyone will express their thoughts;

2. Search for elevator-related algorithms on the Internet and discuss and determine the solutions;

3. write code together;

4. Perform debugging;

 

Information Hiding

Information Hiding refers to hiding certain information, including attributes or methods, during module design. It is not accessible for other classes that do not need such information. Information Hiding improves data security, prevents illegal changes to information in unrelated areas, and facilitates modular design of programs.

Interface Design

Interface Design. In simple terms, an interface is a template or contract that only specifies the functions required, rather than the specific details. By using interfaces flexibly, code vitality and portability can be increased.

Loose coupling

Coupling refers to the degree to which one element has a direct understanding of another element. Loose coupling is a method of connecting components in a system so that these modules can depend on each other within the minimum feasible range. The loosely coupled architecture can reduce the overall complexity and dependency. Each module has its own independence and transmits information only through messages. modifying a module does not damage other modules, it is convenient for us to modify and manage different modules.

 

 

Design by contract

Contractual Programming

Contractual design is a method for designing computer software. This method 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 precondition refers to the caller's responsibility to call a function and must be a true condition. When a function is violated, the function will never be called and data is transferred; the post-Condition refers to what the function can do and the state of the function completion type. The fact that the function will end and will not endless loops; the non-variable type indicates that the condition is always true from the caller's point of view. During the internal processing of the function, the non-variable type can be changed, but after the function ends, when the caller is returned, the non-variant must be true.

Advantages:

A contract makes the document better. A contract is an inherent component of a public view of class characteristics. with a more reliable document, you must check assertions during running, in order to ensure that the developed contract is consistent with the actual running status of the program; assertions define the expected results of the test and are maintained by the Code, so that the program has clear test guidance; it not only benefits accurate standards, but also enables programmers to continue working in the way they are familiar.

Disadvantages:

Assertions cannot be inherited along the inheritance hierarchy. If you redefine a basic method with a contract, the assertion that implements the contract will not be called correctly. You must manually adjust the class without changing the style, and the basic contract will not be implemented automatically.

 

Code contract

The program code contract is. the new function of Net Framework 4.0 is a solution proposed by Microsoft for the concept of contractual programming. It is mainly composed of three types of contracts, namely, the precondition and the precondition, and the non-variant object, you can easily add verification program code to the program code, reduce the program error rate, improve the program quality, or integrate unit testing to reduce the workload of unit testing, or even integrate the Document Manager, make the output program file more detailed.

 

 

 

Unit Test

 

The UML is as follows. The first is the whole, and the second chapter is more detailed.

Key and uniqueness of algorithms: our algorithms come from an elevator algorithm summary in the blog. We feel that the scan algorithm and the improved look algorithm are excellent, so we adopted this method:

The scanning algorithm (SCAN) is a service request in order according to the floor sequence. It allows the elevator to run round-trip continuously between the bottom and top layers, during the operation, the response lies in the requests on the same floor as the elevator operation direction. It is efficient in searching for floors, but it is a non-real-time algorithm. The scanning algorithm effectively solves the problem of elevator movement. In this algorithm, the order in which each elevator responds to a passenger request to enable a passenger to receive services is determined by the distance between the position of the passenger who sends the request and the current location of the elevator, all requests of passengers with the same operation direction as the elevator are completed during an electric upward or downward operation, eliminating the need to move the elevator back and forth frequently [2].

The average response time of the scanning algorithm is longer than that of the shortest floor time priority algorithm, but the response time variance is smaller than the shortest floor time priority algorithm. From a statistical perspective, the scanning algorithm is more stable than the shortest floor time priority algorithm.

The look algorithm [18] is an improvement of the scanning algorithm. For the look algorithm, the elevator also runs between the bottom and the top. However, when the look Algorithm finds that there are no requests in the direction of the elevator, it immediately changes the operation direction, and the scanning algorithm needs to move to the bottom or top layer to change the operation direction.

The key points of our algorithm are two points. One is to scan the shortest floor of a route condition, and the other is to automatically turn around when no command is scanned in the current direction. In this way, from the stop of each layer to the stop of the nearest floor, saving a lot of time.

 

Pairing project: Elevator

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.