"Test-driven software development", independent of testing

Source: Internet
Author: User
Test-driven Development is isn't about testingNovember 3, 2003 Summary
I am always on the look out for good questions to ask candidates in an interview. Not the ' How many oranges can I fit in this '? "kind of nonsense (the stock response to which are apparently" with or WI Thout US standing in it? "). by Dan North
Page 1 of 1

I am always on the look out for good questions to ask candidates in an interview. Not the ' How many oranges can I fit in this '? "kind of nonsense (the stock response to which are apparently" with or WI Thout US standing in it? "). Nor The picky, encyclopedic type such as "in the Javax.obscure.DustyCorner class, which method throws a Fullydocumentedexc Eption? " (If you don't respond with "I would check the Javadocs" on the grounds so you actually know, you really ought to get OU T more.)

Instead, I like the sort of technical question that allows candidates to demonstrate real insight; Where they can show not only technical depth and breadth, but also a mature understanding of the software development proc Ess. So I am delighted when a colleague offered me a perfect interview question, namely: "What's the point of Test-driven Dev Elopment? "

Test-driven Development (TDD) have grown out of the Agile Software Movement (www.agilealliance.org) and Extreme Programm ING (XP) in particular. Extreme programming stipulates a set of best practices that collectively encourage core values such as feedback and simpli City. The feedback occurs in the form of tests, by delivering in short iterations, and by the simple expedient of talking to one another. The simplicity comes from the process of refactoring-ruthlessly-and from only delivering exactly what's the software has To does right now.

Kent Beck, the original champion of XP, have extracted the essence of its development practices and named it Test-driven de Velopment. And so to the model interview answer. The point of TDD was to drive out of the functionality the software actually needs, rather than what the programmer thinks it Probably ought to has. The It does this seems at first counterintuitive, if not downright silly, but it isn't only makes sense, it also quickly becomes a natural and elegant to develop software.

We start by writing some client code as though the code we want to develop already existed and had been written purely to Make your life as easy as it could possibly is. This was a tremendously liberating thing to Do:by writing a model client for our code, in the form of a test, we can Defin E programmatically the most suitable APIs for our needs. In addition, we assert the behavior we want.

Obviously this won ' t even compile, and this is the counterintuitive part-the code that would sit on the other side of The API doesn ' t even exist yet! The next stage is to write the minimum amount of code to get the test compiling. That's all, just a-compile, so you can run the test (which at this stage would fail). IDEs such as IntelliJ idea or the open source Eclipse would generate missing classes and implement missing methods for you. Now, and is now, you write the application code to satisfy the test. The final piece of the puzzle is to refactor, the code so it's as simple as it can be. This then becomes your development rhythm:write a test, write some code, refactor.

Writing the test before you write the code focuses the Mind-and the development process-on delivering only what's abs olutely necessary. In the large, this means, the system is you develop does exactly what it needs to does and no more. This on turn means that it's easy-to-modify-make it does more things in the future as they was driven out by more tests.

We keep the tests we wrote and run all of them, often, to make sure the system does everything it's supposed to do (and T O Alert ourselves immediately if we break any existing functionality). However, the extremely useful test suite we ' ve created is very much a secondary benefit of the TDD process.

So if you're sitting in a interview and someone asks you on testdriven development, remember that it's not about the Tests It's about seeing what little you actually need to doing and how cleanly you can do it! If someone asks you to fill a A-class with oranges? Well, I'll leave that.

What does you think? Join the Feedback to this item.

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.