HTML and CSS Reference
In-Depth Information
serves as an additional client to any code in addition to the application as a whole.
Serving two clients makes it easier to spot tight coupling than writing for only a
single use case.
2.4.3 Forcing Conscious Development
Because each iteration starts by writing a test that describes a particular behavior,
test-driven development forces us to think about our code before writing it. Thinking
about a problem before trying to solve it greatly increases the chances of producing a
solid solution. Starting each feature by describing it through a representative use case
also tends to keep the code smaller. There is less chance of introducing features that
no one needs when we start from real examples of code use. Remember, YAGNI!
2.4.4 Productivity Boost
If test-driven development is new to you, all the tests and steps may seem like they
require a lot of your time. I won't pretend TDD is easy from the get go. Writing
good unit tests takes practice. Throughout this topic you will see enough examples
to catch some patterns of good unit tests, and if you code along with them and solve
the exercises given in Part III, Real-World Test-Driven Development in JavaScript,
you will gain a good foundation to start your own TDD projects. When you are in
the habit of TDD, it will improve your productivity. You will probably spend a little
more time in your editor writing tests and code, but you will also spend considerably
less time in a browser hammering the F5 key. On top of that, you will produce code
that can be proven to work, and covered by tests, refactoring will no longer be a
scary feat. You will work faster, with less stress, and with more happiness.
2.5 Summary
In this chapter we have familiarized ourselves with Test-Driven Development, the
iterative programming technique borrowed from Extreme Programming. We have
walked through each step of each iteration: writing tests to specify a new behavior
in the system, running it to confirm that it fails in the expected way, writing just
enough code to pass the test, and then finally aggressively refactoring to remove
duplication and improve design. Test-driven development is a technique designed
to help produce clean code we can feel more confident in, and it will very likely
reduce stress levels as well help you enjoy coding a lot more. In Chapter 3, Tools
of the Trade, we will take a closer look at some of the testing frameworks that are
available for JavaScript.
 
 
Search WWH ::




Custom Search