Monday, August 27, 2007

Developer Testing is Habit Forming (and Habit Changing)

A while back Tim Ottinger wrote a great article about how "Testing Will Challenge Your Conventions". Among the points that really hit home for me were -

  1. "Interfaces suddenly seem like a really good idea...". Mock objects can be so useful when used correctly that creating an interface is often the first thing I do.
  2. "Singletons and static methods no longer seem like a great way to do work...". As I hope everyone knows by now the Singleton pattern is way overrated and makes writing truly isolated unit tests very hard.
  3. "Private makes less sense...". I still struggle with making a method public just for testing but sometimes there is no other way. Whenever I find the need to do so, I give my design a hard look to make sure it is as good as it should be.
  4. "You need to be able to pass a class everything it might need at construction time...". To write isolated unit tests your classes cannot configure themselves. Of course long constructor parameter lists can be a problem but I can use the builder pattern as one way to counter that.
  5. "Smaller methods are the norm." When I think about the size of methods I write now compared to a few years ago I am amazed at how small the methods are now. It is getting to where I can't read or don't have the patience to read methods over 10 to 15 lines long.
That's a few of my thoughts go read the whole things for yourself.

4 comments:

Joshua Smith said...

Thanks a lot for writing about useful review. It needs to know that iphone app development could help in your business by installing custom development software apps. Also you may turn your attention on outsourced enterprise content management software.

Joshua Smith said...

Thanks for well done posts. Let me mention about home insurance rates for USA policy owners home protection companies. Save on free online rates on homeowners insurance.

Joshua Smith said...

Thank you for posting this great info. You have affordable chance to clarify casino affiliates. The best casino affiliate programs such as acelive and great poker rooms such as redbet affiliate.

Joshua Smith said...

I'm glad to know more and read this great review. Here we are willing to share with cheap instant insurance that is provided by major auto insurance companies. You may save on homeowners insurance rates which allow you to obtain affordable cheap policy.