TDD makes the problem emerge earlier

Source: Internet
Author: User

I have been using TDD for Development recently. I have realized that the shortcomings of TDD really affect the development progress. However, I have also realized that it is an excellent aspect of TDD, that is, to let the problem emerge earlier and to rebuild it.CodeYou are also very confident. In fact, mostProgramThey are very confident in their writing capabilities, and think that there are few defects in writing code. However, the actual situation is that most of the defects will be exposed later in development. This is also one of the main reasons for our programmers to work overtime every day. A very simple example:

Int add (int A, int B ){

Return A + B;

}

What is the problem with this function? It is very simple as an addition. OK. We may have considered integer overflow, but when our project is busy, we may have thrown such code into the product. After one day, I found that the program ran and traced it for half a day. Oh, it turned out to be here, and I hate it. Obviously this is not a good method, so we should spend more time on unit testing to reduce the number of overtime work. For the above example, we can change the return value to the long type. Sometimes testing is really hard to write, such as databases, multithreading, network access, etc. But there is always a way to do it, as long as you don't want to do it.

Related Article

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.