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?