Category Archives: Books

Unit testing 001

“Man, I just love unit tests, I’ve just been able to make a bunch of changes to the way something works, and then was able to confirm I hadn’t broken anything by running the test over it again…” — http://stackoverflow.com/a/67500

The benefits of unit testing are well known, as are the many reasons that are offered when asked “Why don’t you do it?”. The arguments I hear over and over are:

  • “It takes too much time.”
  • “Our code isn’t suitable for unit testing.”

I’ve discussed unit testing with many people in the past years and at some point, I discovered one of the main reasons behind the arguments that were actually offered. We human beings find it much easier to say “It’s not possible”, “It’s too expensive”, “I don’t want to” or “I won’t start doing this until I’ve seen it work” (this one I encounter surprisingly often and makes me smile nowadays) than to admit:

  • “I don’t know how”

Continue reading

Contrafreeloading

“Jensen discovered (and many subsequent experiments confirmed) that many animals — including fish, birds, gerbils, rats, mice, monkeys, and chimpanzees — tend to prefer a longer, more indirect route to food than a shorter, more direct one. That is, as long as fish, bids, gerbils, rats, mice, monkeys, and chimpanzees don’t have to work too hard, they frequently prefer to earn their food. In fact, among all the animals tested so far the only species that prefer the lazy route is — you guessed it — the commendably rational cat.”

— Dan Ariely, The Upside of Irrationality (62)

Testing and refactoring

“When you don’t really know how long it is going to take to add a feature and you suspect that it will be longer than the time you have, it is tempting to just hack the feature in the quickest way that you can. Then if you have enough time, you can go back and do some testing and refactoring. The hard part is actually going back and doing that testing and refactoring.”

— Michael C. Feathers, Working effectively with legacy code (59)