Computing Reviews
Today's Issue Hot Topics Search Browse Recommended My Account Log In
Review Help
Search
Quality code : software testing principles, practices, and patterns
Vance S., Addison-Wesley Professional, Upper Saddle River, NJ, 2014. 256 pp. Type: Book (978-0-321832-98-6)
Date Reviewed: Nov 6 2014

Code’s testability is increasingly being viewed as its defining attribute. In 2005, Michael Feathers defined legacy code as code lacking tests [1]. Stephen Vance, by naming his book on software testing principles, practices, and patterns Quality code, posits the thesis that quality code is code that can be automatically tested. His argument is that code style can nowadays be relegated to the integrated development environment (IDE) or the editor. Furthermore, he argues that many other sources of error can be tracked through modern static analysis tools, while simplicity can be achieved through reuse of powerful libraries and automatic code generation. These factors, he believes, promote testing as the software craftsmanship practice that will deliver the most benefit.

The book starts with a presentation of the principles and practices of testing: testing’s role in software engineering; why testing should focus on intent rather than implementation; the tension between encapsulation, brevity, and testability; and basic testing good practices. Although experienced developers will find many of the recommended practices obvious (minimize coupling, use available facilities, write small tests, and separate your concerns), it is nice to have all of them grouped together in a chapter for reference.

The second part of the book deals with testing and testability patterns. These are recipes (typically presented in Java with some JavaScript and Perl used as well) for writing well-structured and well-behaved tests. Some of the patters, such as verification by injection, are not well known outside the testing community, while others, such as those dealing with error conditions and seams, put order in the chaotic universe a test writer often encounters. The chapter on testing parallelism is underwhelming in the advice it provides (step one for reproducing a race condition: “identify your race condition”), but this is also a devilishly difficult area to work in.

The book ends with two fully worked examples, which allow Vance to showcase in practice the advice he dishes out in the book. Both are available as a series of micro commits on GitHub, allowing readers to see how code can be tested in practice. In the first example, Vance writes a Java program from scratch using principles of test-driven development (TDD), while in the second, more challenging, one he adds tests to existing JavaScript production code. Interestingly, the second exercise uncovered three bugs and some dead code, thus demonstrating in practice the value of testing.

Quality code is geared toward experienced Java developers with some testing experience; people who are already familiar with the JUnit framework and the use of Java annotations. Although such readers are often hard to please, the book is liberally sprinkled with clever testing techniques that many developers will appreciate. I enjoyed reading how log4j can be repurposed for testing intermediate values and how small gdb scripts can be used to locate concurrency problems. On the other hand, other examples require in-depth knowledge of relatively specialized technologies. Consequently, readers unfamiliar with the Spring framework and JSR 330 are unlikely to be able to follow the examples of dependency injection.

Stephen Vance is clearly a person who knows about testing, is passionate about it, and sets out to improve our profession’s craftsmanship through his knowledge and experience. Testing may not be the answer to all problems of software engineering, but it can certainly lead to better code. This book is a valuable resource for all practitioners who strive every day toward this goal.

More reviews about this item: Amazon

Reviewer:  D. Spinellis Review #: CR142907 (1502-0108)
1) Feathers, M. C. Working effectively with legacy code. Prentice Hall, Upper Saddle River, NJ, 2005.
Bookmark and Share
  Reviewer Selected
Featured Reviewer
 
 
Testing And Debugging (D.2.5 )
 
Would you recommend this review?
yes
no
Other reviews under "Testing And Debugging": Date
Software defect removal
Dunn R., McGraw-Hill, Inc., New York, NY, 1984. Type: Book (9789780070183131)
Mar 1 1985
On the optimum checkpoint selection problem
Toueg S., Babaoglu O. SIAM Journal on Computing 13(3): 630-649, 1984. Type: Article
Mar 1 1985
Software testing management
Royer T., Prentice-Hall, Inc., Upper Saddle River, NJ, 1993. Type: Book (9780135329870)
Mar 1 1994
more...

E-Mail This Printer-Friendly
Send Your Comments
Contact Us
Reproduction in whole or in part without permission is prohibited.   Copyright 1999-2024 ThinkLoud®
Terms of Use
| Privacy Policy