Object-oriented programming first phase of work summary

 

0. Introduction

The summary of the first phase of the design work for the three object-oriented programming jobs, three jobs are all topics on the PTA.

1. The operation procedure summary

(1) three working knowledge iterative relationship

The first job to process-oriented mainly in Java to solve simple math problems; second job to start using Java in the "method" to solve simple problems; third operation introduced in Java "class", be solved by category problem.

(2) gradual transition to the process-oriented object-oriented

From the point of view of three operations, each better than the title of the code reusability of code once subject to more modular and more obvious, after the introduction of methods and classes, the same class of topics only slightly modified, code can be reused. The method of introducing the program to start the transition to object-oriented, introduced on behalf of the class of object-oriented officially entered.

Problems (3) encountered during operation and solutions

① initial submission in Java on the PTA, has not been compiled, after inquiry, that PTA can not appear in Java submit the package and class name must be disclosed class Main.

② In the first operation, the first question to calculate tax rates, large amount of calculation calculation error prone, but also because in many cases, to calculate up some troubleshooting.

③ In the first operation, the fourth question to determine the type of triangle, isosceles right triangle test points do not know how to test, the isosceles right triangle side lengths in a certain irrational number will appear when the input data is very difficult to debug.

④ second first-time job in Java method, not add static modifier in front of the method name defined method, resulting in compilation errors, after that access to relevant information without modifying the static method is an instance method, you need to pass the object use.

⑤ judgment leap year and day of the week subject the second operation, the difficulty is how to know if this is the week that one day this problem by seeking a few days of the day from 0001 on January 1, and then divided by 7, the remainder resulting ready for the week, and when the difference between the number of days required to pay attention to which mixed with the leap year.

⑥ third class first-time job, when writing a program based on a compilation error code that a Java file allows only one public class.

⑦ The third class date job design, implement seek with lower n days prior to the evaluation function arithmetic n days more. If one day plus one day, the largest integer test point obviously time out. N may be applied to the first date, date to determine whether the required number of days in the month, subtract the number of days does not meet next month, if it is required before n days is plus number of days last month, the efficiency of this method a lot higher, but the largest integer n days seeking this test points, on the failure of this method, the current date exceeds the length plus the maximum integer shaping, leading to miscalculation. There may determine whether n is greater than 366, if more than the first year plus, plus the month, the last day by day plus the past, each year, plus n minus 366 or 365, but the difficulty was in the end is minus 366 or minus 365, whether it is a leap year can not be cut this year or next year, according to easily determine, as the date entered is a leap year, and the date happens to be February 29, exactly 366 n, if n is minus 366, there will be non-leap year February 29, this date is not legal, it is a leap year and the date in which n is greater than equal to the date of February 29 should subtract 365, and the following year is a leap year and February 28 date is greater than it should be n minus 366, but it should be less than equal to minus 365. Therefore, an increase in the year, where n should be reduced according to the situation in the case of a leap year or February 28 to February 29 n determines how much reduction in the end.

⑧ Overall, this work encountered a few problems a lot, and PTA test point, can not cover all cases, it causes the program to actually have a logical error but still able to pass all the test points of the case.

(4) These three proportion of time spent working times

Spend the most time was the third operation, at least a second time. As it has been already written a second job when the first job experience, and the subject is not difficult, the second part of the code thirty-four question can also be reused, so a second job to spend twice the shortest time relative to other . The third work in the use of Java classes to solve the problem, but according to the given topic UML diagram design, the subject can be a little difficult for me, so at most a third of the time spent working.

(5) of the process of programming logic rigor of knowledge and lessons learned

Some small programming logic errors difficult to find, needs to be carefully considered, and then modify it too much, so try to thoroughly understand the problem before you do it. In addition, at the same time writing code to write notes, write protect yourself because of too many do not know what to write.

2. Object-oriented design experience

(1) Comparison of process-oriented and object-oriented

Process-oriented analysis is a required step to solve the problem, then use the function to implement these steps, step by step, when used in a call to a turn on it. The object-oriented transaction is to be a problem down into objects, the object was not intended to establish a complete step, but a thing to Miao Xu behavior throughout the problem-solving steps in. Can say that the process-oriented process-oriented, and focus on the object and the object-oriented functions, object-oriented design with respect to the process for better reusability.

(2) Basic principles of object-oriented design appreciated

① a class should have one and only one reason to change it, which means that a class should have only one job. Object or entity should be open for extension, closed for modification. ② call the parent class is also tested in the subclass. ③ high-level modules should not depend on low-level modules, they should depend on abstractions. ④ specific implementation should depend on abstractions, rather than an abstract implementation dependent. ⑤ should not be forced to implement a client interface that do not have access, or that the client should not be forced to rely on their method is not used, the use of multiple specialized interface the interface is much better than using a single.

(3) thinking in the object-oriented programming appreciated

 After the real world is the first object has a class, object-oriented, the first, there is the object after class, class is an abstract object, is a generalization of an object, the object is an instance of the class. Object-oriented world everywhere object, the object has the real-world equivalent of each coin has the "data" and "capacity", object-oriented programming is to turn different objects made out of a variety of command line a.

3. understand and practice tests

The importance of (1) testing for encoding quality

By testing can identify coding errors of logic, as the date of the Third Class jobs, through testing found some loopholes in existing programs, while also discovered the advantages of the test algorithm, which can test out the high efficiency of the algorithm which inefficient algorithms, in addition to pass the test can help solve logical problems, contribute to modify the code.

(2) Design test cases

The most basic test is intended to cover all the functions of the program, to define the range of the test, and then take the maximum value, minimum value, the special value of the test. As the test date to find class design leap year February 29 this particular date is easy to find loopholes in the program appears.

4. Course harvest

After object-oriented programming designed around learning, so I have a preliminary understanding of object-oriented programming for Java also have a preliminary understanding, and my thinking is also a gradual transition from object-oriented to process-oriented. In the coding process, I have also found an object-oriented process-oriented does not have features which also embodies the object-oriented advantages. At this stage, I also learned some lessons harvest, before programming to clear thinking, logic to be tight, write their own comments to prevent the "lost", always know what they are writing. Object-oriented fun but not simple, but also need to be more aware of the object for more in-depth study, only by constantly learning, constantly learning gain experience in order to truly master the object-oriented programming.

5. Recommendations of the curriculum

Hopes to increase the difficulty of explaining, on the difficulty of the job a little explain.

 

 

 

 

 Understand the basic principles of object-oriented switched https://www.cnblogs.com/fzz9/p/8973315.html

Guess you like

Origin www.cnblogs.com/19201520-qxb/p/12631177.html