Knot pair Project Blog--The improvement and analysis of arithmetic problem generation program

Source: Internet
Author: User

first, pair programming

Pair member: Kang Jiahua (three digits after school number 190)

1. Pair Programming Photos

  

  

2. Advantages of Pairing programming

1) Single-player programming, due to the limited energy of everyone, can not be a long time to focus on high-quality programming. In pairs programming, because two people's identity can be interchangeable, can effectively improve efficiency.

2) in the implementation of a function, if a person's algorithm is not good enough, then the other side can propose a more simple algorithm, thereby improving the code quality.

3) in the case of single-player programming, there is a good chance that there will be a loophole in the design of the algorithm, and if some boundary conditions are not taken into account before the algorithm is designed, it will be difficult to detect these bugs during testing. In pairs programming, two of people's thinking will be more comprehensive, it is easier to find the shortcomings in the code.

3. Disadvantages of pairing programming

1) If the pair programming, two people's personality, working time, thinking mode and other personal conditions are too large, it is likely to affect the quality of cooperation. Take this project as an example, because this project is a random team, so there is a great chance to meet the wrong pair programming teammates, leading to the unpleasant cooperation. (Fortunately, I am very happy with this cooperation.)

2) before pairing programming, you need to do some preparatory work, such as discussing the design ideas, determining how to implement the algorithm, and the design of the user interface, and so on, the pair programming may consume more time than the single-player programming. Taking this project as an example, since the project was modified on the basis of individual projects, if two people's first code style or algorithmic differences are too large, they may encounter difficulties in writing new projects.

4. Advantages and disadvantages of pairing partners

1) Advantages:

A) programming efficiency is high, each time in a very short period of time to complete high-quality code.

b) The code is very rigorous, written out of the software to take into account a lot of detail issues.

c) The code style is easy to understand (perhaps because it is compared to my style), when looking at the code he wrote, there are very few things to see.

All in all, really is a very reliable small partner, the completion of the code is not only high quality and fast, every time you see the code he wrote often found a lot of the details of their own, and often with some I can not think of a very simple algorithm (for example, when the expression is equal, He gave a very ingenious idea and solved the problem very simply.

2) Disadvantages:

A) There are no shortcomings, because it is really too reliable, if you want to say where can be improved, the code is relatively few comments, if it is the first time to contact the project, understanding may encounter some problems.

5. My strengths and weaknesses

1) Advantages:

A) think more tightly and be able to cover the vast majority of situations when designing algorithms or designing unit tests.

b) Easy to communicate, two people in the co-operation is very smooth, no conflict or problems encountered.

c) Thinking ability, basically encountered problems can be in a short period of time to come up with the corresponding algorithm.

2) Disadvantages:

A) sometimes lazy, after figuring out the algorithm is not very willing to write code to achieve.

b) The efficiency is not high enough, although in this project their own tasks are completed on time, but a large part of the reason is that the assigned to my task is relatively simple, and the really complex part of my pair of partners have been completed.

second, the design method 1. Information hiding

Information hiding is one of the most important factors in object-oriented programming, if the complex information inside each module can be hidden inside the module without being exposed to the outside world, it can effectively improve the encapsulation of the whole project.

Taking this project as an example, there are many properties inside the core module and auxiliary functions that are constructed to implement the algorithm, but these are set to private type and cannot be observed outside, only calculate, produce, Judge, Setting these four functions, and the meaning of each function's arguments and return values is very concise and straightforward, and the caller does not have to consider how these functions are implemented at all.

2. Interface Design

The design idea of the face interface is especially important when the team develops the software, which can effectively improve the efficiency and synchronization of the team work. Just as before a project is implemented, if you can identify the interfaces that each module needs to implement, then the entire team can start implementing all of the modules at the same time without having to complete the project in one layer.

Take this project as an example, although this project is very small, do not need the interface design, but it can still appreciate the characteristics of interface-oriented programming. For example, core module core and user interface interaction, if the implementation can determine the writing core needs to implement the interface, then the core module and user interface can be completely at the same time, when the project is relatively large, this method can greatly improve the efficiency of the entire team.

3. Loose coupling

In my opinion, Loose coupling (loose coupling) and information hiding as well as interface programming are essentially similar, if information hiding and interface design can be implemented, In the interface design can avoid multiple modules at the same time access to a variable or a set of data, it can ensure that the data between all the modules do not affect each other, resulting in undesirable consequences, and naturally realized the loose coupling.

third, contract programming

In contract programming, we need to make the invariant of each class and the precondition and post condition of each method in advance, it is easy to detect the correctness of the method when implementing the concrete method, and also has the clear solution to the boundary data or the unreasonable data.

If you implement the contract programming, when each method is called externally, if the input parameter does not conform to the precondition, the execution of the whole method will be terminated directly by the assertion failure, and the result will not have an uncontrolled consequence. In addition, if the code implementation of a method has an error stating that the input parameter satisfies the precondition, the method execution result does not satisfy the post condition or does not satisfy an assertion in the invariant, so it can locate the cause of the error very quickly and save a lot of debugging time.

In this project, we did not choose to use contract programming, because in the personal project has been the overall framework of the program has been built, debugging, the meaning of the use of contract programming is not very large. However, the benefits of contract programming can be seen in some detail, such as in the calculation of a class, if a precondition can be used to specify the requirements that the input parameters must meet, then in the case of data overflow or divisor zero, it is simple to judge the error and throw the corresponding exception.

Iv. Unit Testing

For the core class, we designed 23 test points, the code coverage for the core class reached 98.74%, and the test all passed, specifically as follows:

v. UML

For this project we have drawn a UML class diagram, as follows:

VI. implementation of the algorithm

Because I and the knot pair small partner's first project code style as well as the algorithm core idea is similar, therefore in the algorithm formulation aspect did not encounter any very big difficulty, only need to take the first time code as the basis, modifies can.

The entire core consists of four key methods: Calculate (calculates the value of an expression), produce (generates a specified number of questions and answers), Judge (compared to the specified topic file and answer file), Setting (sets various parameters of the produce method).

The calculate and judge methods are primarily dependent on the expression class to implement. The Calculate method in the expression class evaluates the specific result of an expression, stores the answer as a string in the corresponding property, returns True if the correct operation is returned, or False if an error is encountered (for example, a divisor of 0).

The produce method relies on the construction method of the expression class, randomly generating operands, operators, and parentheses, constructing the expression and calculating the result using the Calculate method. If a build error occurs (for example, if the divisor is zero or the same expression is generated), then it is randomly generated again until the number of builds has reached the required number.

The incoming parameter of the setting method is a dictionary type value, so the setting of different parameter values can be passed as a parameter, which is a clever point in the algorithm.

Knot pair Project Blog--The improvement and analysis of arithmetic problem generation program

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.