Object-oriented first four weeks of study and reflection summary

  After four to five weeks of study, I have a deeper understanding of Java, on the job, the first two I did pretty good, feel good about themselves, and perhaps was not yet involved in object-oriented, but for the process, practices and language similar to C, so had a very simple java illusion, always stay to the last day to complete, and I paid the price, the third time jobs directly fail, I learn from their mistakes, analyzed what the similarities and differences of these three operations and the reason for the third time I failed.

  The first job is purely process-oriented, all the code written inside a main, and C language is no different, I have good C programming language so easily took a A. The second method for the preparation of operational requirements in the class, a job goes a step further than the first, but in my case was easily passed. The third work is progressive layers, each question are cross feeling of an era, the first question and the second is a guide, to familiarize students with the definition of more than one class, the third question and the fourth question gave we designed several different UML class diagram, because for OO programming is not familiar with the details between difficult to control, resulting in code that I wrote with the continuous error, coupled with the lack of time led to the final third does not work pass. This is three times the proportion of time spent working for the 1: 2: 5. Third spend a lot of time, but can not reach the results you want, the reason is because of lack of understanding of OO programming, after a few days of reflection, I find OO programming is more rigorous, not only need to consider the boundary value, also require elaborate practical construction and determining a relationship between each class. If the design of great help on the back of good programming, almost duplicate code does not appear, main method will become more simple, but it takes more time for analysis and design.

  Process for the focusing process is, from start to finish programming; object-oriented pay attention to the characteristics of each kind, and a plurality of common kind, a kind of abstraction. Procedural code dedicated to a process, focusing on the simplification of a process and operation efficiency, higher performance than object-oriented; object-oriented features and focus is to abstract things in common, their encapsulation and inheritance, each a-kind only their fair share of things, and therefore reusability is more, the use of more flexible, and each class is closed, a class changes will not affect the other classes, so security is higher than process-oriented and more conducive to the maintenance and modification. Object-oriented single responsibility principle has five basic principles, open closed principle, rely on the principle of reverse, Richter substitution principle and the principle of isolation interfaces. Currently, these five basic principles I know only single responsibility principle and open closed principle, which was most impressed by the single responsibility principle, each class can only concentrate on one thing, such as the farmer across the river wolves class game and sheep and cabbage, wolf wolves class to concentrate on things, like sheep sheep concentrate on things like cabbage cabbage to concentrate on doing something, wolf, sheep and cabbage have survived attributes, so have the determination to survive the method, however, did not eat cabbage action, do not define the class like a wolf and a sheep class eat () method cabbage class. Open and closed principle: for the expansion of open, closed for modification, for each entity, can only expand, can not be modified. Object-oriented main idea is to keep each entity's own independent, individual affects less than whole.

  In order for the test to check for the encoding quality of the code, whether the relevant features, and there is no violation of the basic principles of object-oriented, of course, also need to detect the boundary code. In short, the code written is qualified, need to go through the baptism of testing. If I had to design test cases, I first want to test is the encoding capabilities, the ability to meet customer requirements is the most basic starting point, and secondly to test the individual meets the basic principles of object-oriented, and finally test the boundary value, should all meet, the code is written in qualifying.

  Java learning courses this around, I had a productive session, first change my way of thinking, the transition to a process-oriented object-oriented. Before facing a problem, I always wondered how I do, the process is kind of how? Such writing can achieve the result I expected? Now faced with a problem, I think there is a problem which objects? What are the characteristics of each object in common? Each object to this problem which attributes need to have? Followed changed my mind, I should not underestimate this course, need more time to think, design a viable option. There is to my programming ability has been greatly improved.

  I have some advice for the course, I like the way the teacher teaching the first two classes, the farmer across the river to a knowledge of the game to explain, guide our own design classes and programs, I find it very interesting, but also very open mind can see different design ideas for their own design flaws have a better understanding, thereby improving. I hope that teachers can be more prepared this lesson, and fun, but also to acquire knowledge, but also thought provoking.

Guess you like

Origin www.cnblogs.com/ckb-java/p/12637939.html