Monday, November 9, 2009

How many tests are enough?

I've been thinking recently, "How do I know when I've written enough tests?" The answer came to me in a scenario - I've just finished working on a complicated module, and somebody on my team says, "I need to change some of your code to make my stuff work."

Now, I don't know about you, but I'm protective of my code. It feels like one of my kids. I created it. I put my heart and soul into it. I'm proud of it. I want you to like it, admire it, respect it (and me), but I certainly don't want you messing it up.

So when faced with this scenario, what is my reaction? "No, don't touch that! It took me three days to write it." Or is it, "Sure, just keep the tests passing"?

To me, that sums up everything there is to say about test coverage. Not that test coverage tools and metrics aren't important. They give valuable feedback. But, the bottom line is that tests protect your code. Do you feel safe putting it out into the wild?

Friday, September 11, 2009

A Reading List

It seems as if everyone has published a reading list. As a self-taught programmer, I have read a great many good and helpful books. So, without further ado, here's my list of favorites.

Must Read:

  1. Agile Principles, Patterns, and Practices in C# by Robert C. Martin - This is the single best programming book I ever read. They say, 'when the student is ready, the teacher appears'.
  2. Clean Code: A Handbook of Agile Software Craftsmanship by Robert C. Martin - I would read code samples by Robert C. Martin (Uncle Bob) and think, 'How does he write code like that?'. This book shows you exactly how he does it.
  3. Refactoring: Improving the Design of Existing Code by Martin Fowler -This is a reference you should be using multiple times per day. To improve an existing code base, pick a code smell from the index on the last 2 pages, and go through the code applying the appropriate refactoring everywhere you find the smell.
  4. Pragmatic Unit Testing in C# with NUnit, 2nd Edition by Dave Thomas & Andy Hunt - If you are new to unit testing and/or test-driven development, this book will help you over the initial learning curve.
  5. Agile Estimating and Planning by Mike Cohn - If you are as uncomfortable with time-based estimates as I am, this book will be a revelation. Why guess when you can have actual data?
  6.  About Face 3: The Essentials of Interaction Design  by Alan Cooper - This book changed the way I think about software. I NEVER used to think about users at all. Now as I use software, I notice all the little things that bother me, and think about how not to inflict the same annoyances on the users of my software.
  7. Misko Hevery is my new hero. His articles on testability and object-oriented design (OOD) have answered a great number of questions for me.


  1. Programming Ruby 1.9 by Dave Thomas - I really enjoyed learning about a different type of language than what I normally work in - C#.
  2. Code Complete 2 by Steve McConnell
  3. Effective C# by Bill Wagner
  4. Building Applications and Components with Visual Basic .NET by Ted Pattison & Joe Hummel - Introductory level, but very solid and clear. It is dated since it targets .NET 1.1, but the concepts are still very valid.