Wednesday, March 24, 2010

Design principle: question your assumptions

A lot about good software engineering and design is about listening - listening to that little voice in your head that's telling you you're pushing it, forcing a design or an implementation onto a problem that's not a good fit.

It's very hard for me to listen to this voice when I've got a particular solution in mind, and I'm plugging away implementing this solution, and if I can just get past this next hurdle, it will work, dammit!

Yesterday I finally noticed I was banging my head against a problem.  I thought about what the struggle was, and I realized that most of my pain was in trying to coordinate two separate threads of control through the system - one doing updates and one posting those updates to listeners.

So I decided to apply a common principle for me: question your assumptions.  Did they really have to be coordinated?  I contacted some other members of the team and our product manager and asked what they thought.  It turns out there was much more flexibility than I thought was possible.  If I tried to stop having absolute control, as it were, relaxed a bit, and let things be a little loosy-goosy, then my overall design became much less coupled and thus much simpler.  Ahhh....

It reminds me of the beauty of eventual consistency - if you let go some of your tight constraints, it's amazing how it opens things up and brings new possibilities into the solution.

No comments: