OO three weeks, from Java small white to one foot to get started

Source: Internet
Author: User

write in front

  Three weeks ago, I really do not have much knowledge of Java programs, even the basic input and output will not, so far clear remember to write the first homework when the helpless; to the second assignment, the basic syntax structure of Java and read through the guidance book, based on the completion of the job goals, and the third job, After a cursory tour of the contents of the guide, "think" this job is only on the basis of the last homework to make minor changes, the results hit a loud bang ... Three times, from the new language to accept the hesitation, to the basic grasp and the satisfaction of small test skills, and finally experience the "underestimate" the contents of the program to write the process of despair-three different feelings, let me the first experience of Java memory deep.

the first homework in the wandering

The first homework, can be said in the case of completely do not understand the Java language, the bite-bullet to write out. This job has only one class main; The code inside is similar to the C program in addition to specific system calls such as input and output, only some of the functions "meaning" are split into several methods. Therefore, the measurement analysis and the class diagram are not posted. But the most important thing in this homework is to master the use of regular expressions and some common functions in Java, and while this job is written in the process of processing, in the process of splitting methods, this work in imperceptible to me transmission "object-oriented" thinking, but also for the second time the smooth completion of the work to pave the way.

the bug of this job mainly exists in its regular expression still has the flaw as well as the boundary condition consideration question, the former should in the oneself constructs the test case to examine, the latter lets me learn the try-catch use. This , the first homework also let me understand the very very important two points: one: must carefully read the instruction book! Mutual testing I got the classmate is because the "error" output in order to "error" caused the public to test the red a large ..... This also gives me to choose the bug caused a lot of difficulties, because the left to pick the bug points are not many, two: seriously write readme! Finally, I give this classmate to choose one, that is, the leading +00: The processing, is to drill the "loophole" of the readme.

the second job to meet after the small test skill

Through the use of network resources such as class, csdn and so on, the basic structure of Java was mastered before the start of the second operation. Therefore, this homework write down feeling still relatively smooth, also calculate oneself first true meaning of object-oriented program. This guidance book stipulates that the program must be divided into at least five classes to execute, on the basis of which I added a main class as a program execution portal. The class diagram and measures are as follows:

Advantages:

Is it a good thing to write fast? ........ ....... As the homework before writing a full idea, so one night will be the basic ability to write almost, and then spent an evening later "patching" and testing. It has been written very quickly, especially compared to the first and third assignments. As to the merits of the procedure itself, compared with itself, this program in the "Object-oriented" The thought has made great progress, not like the first homework as a class to carry out the end, difficult to maintain.

Disadvantages:

Although there have been some "object-oriented" meanings compared to the first job, there are still problems: first of all, in the six classes of the program, the Scheduler class and the floor class became "soy sauce"--two classes that were not used in my second assignment program. Conversely, it can be seen from the Nested Block depth is very high, the other four classes, in addition to elevators, directives, instruction queue defines the basic properties and methods, most of the other implementations are written in the main class main function. This also brings trouble to the design of the third job. The main function uses the Do-while loop to read the input to the console, with a large number of if-else judgments in each loop. The workaround may be to detach these if-else judgments as methods from main.

Bug Analysis:

This operation is not a problem when the test, the mutual testing phase has not been singled out the bug, which makes me a bit surprised. Try to keep it going.

the third job struggles in despair:

The third job is a little extreme operation of the taste: in the Friday class in the last teacher assignment, browsing through the request after the mind is to add a piggyback function just, so I did not want to start early. Results Monday Night began to write the third homework only to think about the algorithm and the structure of the program for nearly four hours, a night after the past basically did not write; by the Tuesday evening the idea is almost, wrote a night to go back to the bedroom to relax, Discuss with your roommate and try to run a sample of your roommate's build before you find out that you have a lot of things to think about. Wednesday in the daytime no class, has been debugging their own programs, but every time a bug fixed and then a new bug, quite a bit pay Paul feeling ... By the end of the evening, when the DDL was barely finished, it was hard to imagine what the results would be like, and the feeling of despair was truly unforgettable. Although finally finished the job, but the price is my code is very bloated, even worse than the second job, the floor class has no practical significance, scheduler sub-class Sche there are hundreds of lines of code, which has a lot of repeating content. The class diagram is as follows:

Advantages:

The algorithm takes time as the cyclic variable to scan the homogeneous instruction, and judges the homogeneity before executing an instruction and judging the piggyback instruction, which effectively avoids the case of omission or miscalculation of the homogeneity instruction. When executing the instruction, the floor is used as the loop variable, which ensures that the execution of the instruction conforms to the order of the floor and not the time order. can also sift out the next round of the main instructions.

Disadvantages:

As stated above, because this job is written in a relatively hasty, resulting in extremely bloated code, which makes debugging a little difficult. In addition, repetitive code is not split as a method, making the code less friendly to read. At the same time, floor class is still a decoration, not give practical significance, undoubtedly these will give the next multi-threaded work difficulties. As with the second job, although this time the main algorithm from main to the Sche, but due to improper timing and experience, code style problems, in the judge method nested too many loops to judge the homogeneity, piggyback, you can try to use these judgment code as a method from the judge separation.

Bug:

The operation of the test and mutual testing there is a bug about the piggyback instruction, that is, the ER type of elevator instruction in the target floor can be located in the elevator current floor and elevator target floor outside the range. This is clearly written in the instruction book, and I did consider it at the beginning of the writing process, but was "de" dropped during the post-debug process ... Such a low-level error or because their code style is not concise, specification, so that every time the de after a bug can rarely find the normal function of accidental removal. Of course, I have not scheduled the time for homework, resulting in a very short period of work is also a reason.

Experience:

1. Work must start early to write, or to the back of the homework too late when the idea of terror will come out ...

2. Code style to be concise, it is convenient for their own debug, but also for others to read, write notes.

3. Before you write code, be sure to think well, even if you don't bother to write to-do-list also have to clearly know the algorithm that you intend to implement.

4. Each homework according to the recommended structure of the courseware to write, or if the next assignment is on the basis of this job will be a headache.

5. There are times when you don't have to push yourself, and you really don't know what you can write.

6. Some things bite teeth on the past, do a lot of pain, perseverance, after the completion of how easy.

OO three weeks, from Java small white to one foot to get started

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.