What's in a Name? A Lot, Actually.

[article]
Summary:

Good names make a design easy to understand, help clarify intent, and provide inspiration. But those perfect names can be a real struggle to discover. In his book Implementation Patterns, Kent Beck writes: "Finding just the right name is one of the most satisfying moments in programming."

Good names make a design easy to understand, help clarify intent, and provide inspiration. But those perfect names can be a real struggle to discover. In his book Implementation Patterns, Kent Beck writes: "Finding just the right name is one of the most satisfying moments in programming."

I've definitely felt what Kent is talking about. We were in the early stages of building an application; our design was evolving and there were nice clean abstractions that fit together cleanly like puzzle pieces - except this one little annoying class. This class exposed its contents through getters and setters, had no meaningful behavior, and its collaborations with other classes just felt awkward. We knew this meant some abstraction was wrong, so we set out to find some way to delete that class entirely.

But we quickly found that we couldn't delete it - it was a useful class after all. As we struggled to rework the design, my colleague Harlan pondered, "Well if we can't delete the class, how about we rename it?"

It was a simple suggestion, but it had dramatic effects. With a new name, we started thinking about this class in an entirely different way, and everything started coming together. Now that we had this new way to think about the system, we made little adjustments here and there and voila! Everything fit in exactly the right place. You could practically hear all the electrons in the computer singing in perfect harmony.

Brian Foote and Joshua Kerievsky of Industrial Logic had a lot to say about names in their Agile 2009 session "System Metaphor Revisited". They told the story of how they stopped thinking about their online learning courses as a collection of books and started using the metaphor of a catalog of music. This provided all sorts of ideas for the product, from how the user interacted with the system to how the code was organized and named. Using new names inspired their team to re-examine some of their trickier problems in a different light, and ultimately led to creative, elegant solutions.

Do you have a favorite story about discovering a good name?

User Comments

1 comment
Anonymous's picture
Anonymous

<a href="http://c2.com/cgi/wiki?HaveThisPattern" rel="nofollow">I have this pattern</a>!<br><br>Working on some sticky old code the other day, my pair and I were talking about the virtuous cycle that sometimes appears between renaming and refactoring: First, you give a class a slightly better name than it had before; Then, you start to see some behavior that should move there; Then, once you can see what the class really <i>wanted</i> to be doing, you can see an even better name for it. (And, in our case, pull out a few more classes).<br><br>(Also, thanks for the link to the System Metaphor Revisited slides--I had to reluctantly miss that one at Agile.)

September 14, 2009 - 3:10pm

About the author

AgileConnection is a TechWell community.

Through conferences, training, consulting, and online resources, TechWell helps you develop and deliver great software every day.