TITLE: By Any Other Name ... Not! AUTHOR: Eugene Wallingford DATE: August 27, 2004 2:18 PM DESC: good names in the news and on my mind ----- BODY: Everyone knows that using good names in code is essential. What more is there to say? Apparently, plenty. I've encountered discussions of good and bad names several times in the last few weeks. Not too surprisingly, the topic of names came up during the first week of my introductory OOP course. I gave my students a program to read, one that is larger than they've read in preceding courses and that uses Java classes they've never used. We talked about how good names can make a program understandable even to readers who don't know the details of how an object works. The method names in a class such as java.util.Hashtable are clear enough that, along with the context in which they were used, students could understand the class that uses them. Often, issues that involve names are really about something bigger. Consider these:
When a client passes false as the second argument with this message, the result is that the button is disabled. Such code is almost impossible to follow, because you have to pay attention to the guilty argument in order to get even a high-level understanding of the code.
Avoiding this situation is relatively easy. Create a second method with a name that says what the method means:
Not only is Nat spot on with his analysis, but he has come up with a wonderfully evocative name for this anti-pattern, at least for those of us of a certain age: the Wayne's World Method. This name may be too specific in time and culture to have a long life, but I just love it.
I'm not sure exactly what Ward will talk about, and I can't wait to find out. But the title hints that he will follow the thread of names through several of his contributions to our industry. Just think about the role names play in connecting the tissue of a pattern language, the fabric of ideas that is a wiki -- and the domain model that comprises an object-oriented program. And perhaps names play a more central role? I look forward to Vancouver.