Rewards of Good Design

Having been in software for a while now, I have a developed a sense for good design practices. It's not that I consult the GoF patterns book for everything I write, but I can just generally tell when an approach is good or bad, even if there isn't a lot of logical support.

A perfect example of good design paying dividends happened to me yesterday. In my current project, we have distributed components. So that the components can identify each other, they all have ids. In the very first draft of our design, the ids were just Strings. I was certain that there would never be a need for an id that was more complex. Nonetheless, we chose to create a class for the ids that would just be a wrapper around a String. We made that decision because deep down we knew it was the right thing to do, even though at the time, it seemed less like correctness and more like obsessiveness.

Yesterday I had to change the component id from being a String to being a compound element composed of a URL and a JMX identifier. NetBeans told me the component id was used in 172 places! There were, however, only about 5 places where ids were created. Everywhere else, the actual contents of the id were irrelevant. If we had just used String ids, I'd have had to change the type of the component ids in all 172 places, and it would have taken me all day. Instead, I was able to make all the changes, including writing a unit test for the new id class, in about an hour.

Comments:

Post a Comment:
Comments are closed for this entry.
About

templedf

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today