Intention Revealing NamesOne of the SmalltalkBestPracticePatterns. (Quick note for Smalltalkers: "selector" would be used instead of "method name", see IntentionRevealingSelector)
[These still don't reveal enough information. What does getPosition return if the search item isn't found? 0? -1? Does it throw an exception? You need to document all these cases somehow and somewhere and the name isn't sufficient. And since you need to know about error conditions to use the method, you have to look it up anyway, so there's no point in getting too worked up over the names (This is one of my problems with supposedly self documenting code). "includes" is the best of the bunch, but it's not equivalent to the other methods.]
To test a name:
I think this pattern is flawed, see my reasoning in IdentifiersRevealIntent for elaboration. Things should not be named after their intent, but after their essence, that is, not after why they are but after what they are. It should be self-evident that a name should tell you what something is. -- PanuKalliokoski
Note: If someone says, "Let's use IntentionRevealingNames here", they'd probably mean: "Let's ExtractMethod just to reveal intent (as opposed to doing the extraction to deduplicate)". Like a living, executing comment.
It is (or should be) implied with all selectors that they should reveal intent.
Why not just use a comment?
See IdentifiersRevealIntent, IntentionRevealingSelector, IntentionNotAlgorithm.
See IntentionRevealingSelector, for Smalltalk-specific usage.
See this for a real world example of intention revealing names http://blog.eliotsykes.com/2009/05/23/intention-revealing-naming-a-real-world-example/
CategoryCodingConventions CategoryCodingIssues CategoryNaming
EditText of this page
(last edited June 2, 2011)
or FindPage with title or text search