How to ensure that your function code does not make a mistake

Source: Internet
Author: User

A few days, the program is quickly baked by the bug, after a series of details of the process of collapse, I have a new understanding of the problem of program quality, how to build robust and efficient software?

Responsibility? Wit? Experience? Craftsman Spirit? or from the specific method and the implementation of the process of self-study it ... 1 The level of control over requirements is too shallow (requires two confirmations to review the code)How many times have you studied demand since we started the first demand Chuanjiang? This question I must now pay attention to, take for granted some function, because by the imagination and others busy when the verbal confirmation as the demand basis, the function completes is also the verbal confirmation, originally does not appear the question only then relies on other people's rigorous test and the teammate occasionally discovers the condition to discover and confirms, But the problem hidden in the code details is basically a dark corner, sealed in a hidden area, until a critical moment, the bomb in this place will suddenly fly out, let you unprepared, because the problem is the problem, not because you do not see him disappear. 2 Learning Test IdeasAlways feel that the technical toolbox is the implementation of this idea is very problematic, collected the implementation just found the parts and tools, to make something to use, who in use, to jump from the simplest scenario, deduction at least three times above, that is, the creation of the branch, in fact, Dr. Zhang said more judgment catch abnormal is not enough, We will continue to deduce on the basis of the first deduction and iterate the design using the positive feedback principle. 3 Judgment of the durationWhen does the design finish? When did codeing finish? When do I submit a test? In the heart has the number, if the target duration to, submit the test code if not done already self-test more than 50%, it can not be easily put to the tester to take over the quality assurance task, because then the finished product has no quality at all. If you submit a test, then the tester will have a lot of doubts about your functional error, it will waste a lot of unnecessary time, this is fatal to the quality, time wasted! It may be more valuable to re-create a new software if you take time to explain it to someone else, time spent on the design to start over, low-cost working hours brought about by a frustrating mood, and the time to work on the change and confirmation time of a bug. 4 developing code review and refactoring plansWhat should I do after the code is submitted for testing? Passing? A leisurely? Shopping? Rest? No, these can not be dry, spend two hours, detailed list of the program, to see at least once, believe me, it is easy to see the wrong place, and then you will be glad to do this thing. Tell me what I've seen. In a background project normal business run through the case, I thought the completion of the task, until I looked at the bug list, there are some I think very small problem, to the back of the code, a large and small logical loopholes appear, from a branch and a point to many places the invocation of judgment and implementation of the way there are problems, So the process of patching began. From the beginning of the test to patch, has been hit to the end of the test, the heart is still not practical down, really torture people, although this panic and fear may not appear, if the heart of all done things have a bottom words. This time the program list can help the programmer to the bottom of the mind, because the things are listed there, look at the name and look at the uncomfortable look two times think the parameters of the package is somewhat redundant, if the type or array pass will be more extensible. See three times think public methods in multiple classes should be drawn out to throw a place to maintain. See four times feel that some implementations with generics should be implemented more easily. See five times feel the extensibility of the business if it can be done with the base class and interface can save a lot of things later. Look at six times that the code is simply thrown into the trash can, or it is more comfortable to do it again. And then there's no more. 5 What makes me not do theseDid not do, so did not do, such as now, you think I am thinking, research pursuit of truth, in fact, I am in the wrangling.

How to ensure that your function code does not make a mistake

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.