Skip links

Book Review - Growing Object-oriented software guided by tests

10 March 2012 14:30 - by Freek Lijten - 9 comments

Tags: , ,

Recently I've been reading Growing Object-oriented software, guided by tests (Freeman & Pryce) and I thoroughly enjoyed it. I've been getting into unit testing and test driven development (TDD) lately and as such I am convinced TDD works and unit tests are vital to your application.

The only problem is, there is a lot of text on writing unit tests and there usefulness, but I haven't seen much fully worked out examples of a TDD cycle. This book provided exactly that!

First of all, the book uses Java for its extensive examples. If you've written anything in Java (even a reasonably sized school assignment works) you should be perfectly able to understand all code (heck I could and I haven't written Java in ages and never outside of school). If you've never written Java I assume you might have to look up some structures but if you're proficient in another language you should be able to understand the meaning of the code as well. In short, Java is not a reason for stopping to read this post or not buying this book!

The verdict

It may seem strange but I'd like to start out with giving my opinion on this book: It is brilliant! If you don't like reading my post you at least know what you should do next: buy the friggin' book. The book offers some theory concerning agile development, (unit-)testing and code quality but its killer feature is the almost 200 page long example of developing an application the TDD way! In the rest of this post I will shortly highlight different parts of the books and stuff I enjoyed or learned from it.

Part I - Introduction

The book starts out with an expected introduction. It is not large though, the book is written for "the informed reader" by which the authors mean professional developers, so don't expect a lot of background information on the basics. This part offers two chapters which mostly help us establish the same vocabulary. A third chapter that shortly introduces the tools used while writing tests (JUnit, Hamcrest and jMock) concludes this part.

Part II - The process of test driven development

In this part Freeman and Pryce describe their take at test driven development. How do you start with a test driven development cycle if there is no existing system to add a unit test and then a feature to? What will you test first, where will you begin? Freeman and Pryce propose starting with an end-to-end test. This means building, deploying and testing a walking skeleton. With walking skeleton the authors mean the thinnest possible real slice of functionality that can be tested end-to-end. 

What the end's are in such a test may differ. Sometimes you have no control outside of a defined scope (imagine creating a new feature in a huge legacy project), the scope in that case is the boundary of the end-to-end test. See it as one huge integration test if you will.

The authors stress the importance of not starting with testing and writing some model you are already sure you will need. It is important to know if your application will be able to interact with the outside world. You don't want to end up with a perfectly well unit-tested package that is not able to do anything because of wrong assumptions on the outside world.

My first real lesson

Ending up with such a tested package actually happened to me not so long ago. A customer wanted Form fields on a relations relation-card to be set to read-only based on the values of other fields in the same form. Our CRM package has a plug-in structure that allows other packages to manipulate these Forms and Forms are abstracted away in objects so I could set this up quite nicely. I decoupled the software entirely from the rest of the system and gave each well-tested class in the package a single responsibility. All in all it was a great experiment, until I needed the software to actually work inside the plug-in.

Apparently the Form manipulation plug-ins only fire before the data is set... Had I started with an end-to-end test, I would have started at collecting input from the plug-in first. I would have immediately discovered the fatal assumption I made was incorrect. I had no data available inside the plug-in so all my efforts where for nothing.

Luckily for me there was a work-around. This took me some time, but I hugely profited from the fact that I had decoupled the Form parsing and processing from the rest of the system. At least I hadn't done everything wrong :)

Part III - A worked example

As I stated before, this part is the unique selling point of the book. This is such an exhaustive example that completely covers all questions that you might have left after reading part II. I found part II informative and understandable, but the ideas in it only started "living" for me while I was reading trough part III.

The example deals with writing an auction sniper that tries to buy items at an on-line auction until a maximum price is reached or the auction is won. The example is well chosen and complicated enough to resemble an actual task you might have to work on while remaining understandable at the same time.

I can write all I want about this, but you'll simply have to read it to understand why I liked it so much.

Part IV and V - Sustainable test driven development / advanced topic

The last parts are a series of best practices and tips & tricks concerning the writing of unit tests. Consider it a parting-gift. Part IV deals with common situations like testing for complex data structures, naming inside tests and more. Part V deals with testing multi-threaded code, testing asynchronous code and the testing of persistence. These parts are certainly worth your time as well!

Conclusion

If you're convinced of the necessity of automated testing but you're unsure on how to start with actual test driven development, this is a very interesting book. If you're already actively developing using the test driven methodology, you still might like this book. It offers great value for money and is definitely worth your money.


Share this post!

Comments

  1. Łukasz Wojciechowski Łukasz Wojciechowski wrote on 14 March 2012 08:03

    Hi there

    I like your review of this great book. I feel pretty much the same about its content what you felt.

    If you (developers) are on stage when you realized that testing is one of developer tools that you are missing and it makes a huge difference - this book is perfect for you.

    Go - buy it, read it and enjoy it. :)

    Best regards

  2. google advertising rates google advertising rates wrote on 03 August 2014 09:21

    Hi there, everything is going fine here and ofcourse every one is sharing information, that's really excellent, keep up writing.

  3. Orville Orville wrote on 11 August 2014 09:13

    Greetings! Very useful advice in this particular post!

    It is the little changes that will make the biggest changes. Many thanks for sharing!

  4. vigrax cena vigrax cena wrote on 20 August 2014 01:34

    na szcz__cie dla was wszystkich, ja - jako pokornej narratora, ma troch_ wi_cej czasu wolnego, jeszcze stosunkowo skromny dochód rozporz_dzalny i dziewczyna palenia-gor_co . najbardziej przydatnych programów odchudzania zatrudniaj_ wiele ró_nych zasobów w celu osi_gni_cia jak najlepszych wyników . Zapowiada spali_ t_uszcz z brzucha i nieprawdopodobn_ zmniejszy_ apetyt bez konieczno_ci _mudnych i radsny wykonywania procedur .

  5. Fatima Fatima wrote on 11 September 2014 14:24

    Hi there, There's no doubt that your website could be having browser compatibility issues. Whenever I look at your website in Safari, it looks fine however, if opening in I.E., it has some overlapping issues. I merely wanted to give you a quick heads up! Other than that, fantastic site! promotional bags site

  6. buy facebook likes over time buy facebook likes over time wrote on 11 September 2014 20:37

    Hey there are using Wordpress for your site platform? I'm new to the blog world but I'm trying to get started and create my own. Do you require any coding knowledge to make your own blog? Any help would be greatly appreciated! buy_facebook_likes_for_cheap

  7. Gabriele Gabriele wrote on 13 September 2014 12:49

    I absoltely love your site.. Pleasanht colors & theme. Did yoou make this website yourself? Please reply back as I'm hoping to create my own personal site and wan to find out where you got this from or exactly what tthe theme is named. Thank you! how to get free instagram followers and likes fast

  8. business gifts business gifts wrote on 14 September 2014 21:54

    Saved as a favorite, I really like your blog!

  9. purchase real facebook likes purchase real facebook likes wrote on 21 September 2014 09:42

    Hi, i think that i saw you visited my site so i came to “return the favor”.I am attempting to find things to improve my website!I suppose its ok to use some of your ideas!!

Leave a comment!

Italic and bold

*This is italic*, and _so is this_.
**This is bold**, and __so is this__.

Links

This is a link to [Procurios](http://www.procurios.nl).

Lists

A bulleted list can be made with:
- Minus-signs,
+ Add-signs,
* Or an asterisk.

A numbered list can be made with:
1. List item number 1.
2. List item number 2.

Quote

The text below creates a quote:
> This is the first line.
> This is the second line.

Code

A text block with code can be created. Prefix a line with four spaces and a code-block will be made.