Pairing project --- Chen Boxiong & Jia Wei

Source: Internet
Author: User

Through this pair programming, I realized the advantages and disadvantages of Pair programming:
Advantages:
1. It is conducive to improving the project quality and reducing bugs;
2. facilitate knowledge transfer and reduce learning costs;
3. Many people are familiar with the same piece of code to reduce project risks;
4. Work with others and discuss with each other to solve problems faster and more effectively;
5. Individuals are under less pressure.
Disadvantages:
1. For people with different programming habits, Pair programming may cause trouble;
2. When the level of programmers is quite different, experienced veterans may feel very annoyed. Inappropriate communication leads to team discord.
3. The project may fail or be extended due to a long time for programmers to discuss different opinions.

My teammate Jia Wei has some disadvantages:
Advantages:
1. Being Modest and studious, gentle and elegant, and easy to get along with and cooperate with each other;
2. Strong programming capabilities, unique insights on problems, and great help for our paired cooperation;
3. A strong sense of responsibility and the ability to infect people in the same group are involved in the cooperation;
Disadvantages:
Communication between teams is not enough.

 

Q: Read the Information Hiding, interface design, and loose coupling chapters in textbooks and other materials to explain how to use these good design methods.

A: Information Hiding, interface definition, and loose coupling make the program encapsulate well and facilitate the expansion of functions without affecting the reason. In the elevator scheduling project, defines many interfaces such as elevators, passengers, and boarding requests, and encapsulates the interfaces into commons. cs files are used in program, elevator, loaders, and passenger, and these interfaces are used properly in sched, inherit and expand the original simple schedeq class, while expanding the original scheduler class, we also make full use of the above method, the extension staff initialize class and QueueReq class, various judgment conditions are separated from the theme function run () to facilitate later modification and reuse. For example, the IsAtTopFloor/IsAtBottomFloor function judges the boundary conditions of elevator scheduling. LastScheduler defines the latest scheduling scheme, minimize repeated code.

Q: Let's look at Design by Contract and Code Contract to describe the advantages and disadvantages of these practices. It shows how you integrate them into your job.

A: Design by Contract is a Design technique summarized by Bertrand Meyer and is also the main feature of the Eifel language invented by Meyer. However, the scope of this principle is not limited to Eifel, but all programming languages.

Design by Contract uses three types of assertions: post-conditions, pre-conditions, and invariants ). Both the prerequisite and the successor condition are for the operation.
Three Keywords of contractual design:
Precondiction ):
In order to call a function, it must be a true condition. In the event of violation, the function will never be called, and the caller's responsibility will be transferred when data is passed.
Postcondion ):
What the function can do, the state of the function completion, the fact that the function will end, not endless Loops
Class invariant ):
From the caller's point of view, this condition is always true. During the internal processing of the function, the constant items can be changed. However, after the function is completed, when the caller is returned, the unchanged items must be true. (Excerpt from: UML Distilled 3rd edition)
I understand this as follows: The main purpose of rational design is to allow programmers to clearly define the status of a module unit before and after an operation is called, it is a design style and a syntax specification. With the explicit definition of language-level pre-and post-conditions and non-variant expressions, the program structure becomes easier to read and communicate. And the contract is helpful for testing. When writing a contract, you must use a prior condition and a posterior condition to describe the task of each routine, and then write the implementation code in the program to complete the task. Because you have to think about the program in two slightly different ways, you will be able to better understand the task and the method to complete the task of the program. This will also help us identify errors as soon as possible. Testing is more in place, so the code is more reliable to assert that the program is tested at runtime to ensure that the program complies with their established contract. The contract can be disabled or enabled at will, so we can easily repeat all parts of the program. However, assertions cannot be inherited along the inheritance hierarchy. If you redefine a basic class method with a contract, the assertion implementing the contract will not be called correctly (unless you copy them in the new Code ), you must manually adjust the unchanged items, and the basic contract will not be implemented automatically.

Code Contracts is. the new function of NET Framework 4.0, which is a solution proposed by Microsoft for the Design by contract concept. It mainly consists of Preconditions and Postconditions) and Object Invariants. These three contracts can easily add verification program code to the program code, reduce the program error rate, and improve the program quality, you can also integrate unit tests to reduce the workload of unit tests, or even integrate the document manager to make the output program files more detailed.

Code Contracts provides the following four features:
1. Improve the degree of Automatic Testing
2. Static Verification
3. Execution phase Verification
4. file generation

UML diagram:

Algorithm design ideas:

We adopt simple elevator scheduling. According to the proximity principle, the elevator responds according to the recent application. When the elevator is still and Its Historical Status is static, set the number of recent request layers to the target number of floors and the direction to the target number of floors. When the historical status shows a forward direction, the request direction is the same, the most recent requested floor before the current floor advances is set as the target floor and the direction is the historical forward direction until the target floor or the top floor and bottom floor are reached.

Request during elevator operation: Set the requested floor to the target floor and the direction to the historical direction before the current floor advances until the target floor or the top floor is reached, bottom layer (boundary condition ).

When the elevator does not receive a request from the outside, the elevator returns to the first layer (1 layer of traffic is relatively large ).

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.