The Artima Developer Community
Sponsored Link

Let's Reconsider That
The Price Of Two
by Michael Feathers
January 4, 2005
Summary
Sometimes the roadblocks we encounter are our own.

Advertisement

A team using C++.. When I walked in, they had just finished writing the second for loop. Both for loops were sitting, one right after another in the same method.

One iterated a map that associated users and subscriptions with IDs (map int -> std::pair<std::string, Subscription>). The other iterated a map which associated time limits with IDs (map int -> unsigned long) I asked a few questions. Was there a time limit for each subscription and user, and vice versa? Yes. When we add or delete an entry in one map do we have to do the same thing in other map? Yes. Why wasn't there just one map, one which associated each time limit, user, and subscription with an ID?

Why didn't they do it that way?

...

A team using C#.. A model class needs to tell a view that a new item has been added. Seems like a job for .NET's events. A programmer adds an event to the model and registers the view on the event with a delegate. Works fine. Later the team discovers that sometimes when an item is updated the view needs to be notified. A programmer adds a second event and registers the view on the model a second time with another delegate. A few days later, they discover that the view needs to know something else. Another programmer adds yet another event to the model. Now there are three events on the model and only one object registers for them, but you can't tell by looking at the model class.

Why did they do it that way?

Talk Back!

Have an opinion? Readers have already posted 27 comments about this weblog entry. Why not add yours?

RSS Feed

If you'd like to be notified whenever Michael Feathers adds a new entry to his weblog, subscribe to his RSS feed.

About the Blogger

Michael has been active in the XP community for the past five years, balancing his time between working with, training, and coaching various teams around the world. Prior to joining Object Mentor, Michael designed a proprietary programming language and wrote a compiler for it, he also designed a large multi-platform class library and a framework for instrumentation control. When he isn't engaged with a team, he spends most of this time investigating ways of altering design over time in codebases.

This weblog entry is Copyright © 2005 Michael Feathers. All rights reserved.

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us