Counting Belly Button Wrinkles
whenSelectorsTurnIntoDisertationsAndRunOnAndOnNeverEnding
Introspection and statistics are a fun game to play with a Smalltalk image. I've posted a number of these before. Here's todays query:
allCodeSymbols := Set new. Root enumerateMethods: [:class :selector :code | code allSymbolLiteralsDo: [:each | allCodeSymbols addAll: (each runsFailing: [:char | char = $:])]]. allCodeSymbols groupedBy: [:each | (each piecesCutWhere: [:a :b | a isLowercase and: [b isUppercase]]) size]
Ever noticed how you have a hard time coming up with a good method name? Or maybe a good user message key? So you end up typing out something that rivals a novella to explain what it does, all in camelCase? I was doing so earlier, and decided to see how close I was getting to a default development environment's worst offender. I was at 8 at the time. I was beat out by a the method checkForNameSpaceAndDataInZeroOrMultiplePackagesOn: which has 12 words in there.
Have a better one? Leave a comment and share your worst offender.
Comments
[] October 7, 2008 17:19:14.041
Fame includes a method named <code>#privateOnlyCallMeIfYourAreBDFLOrSystemAdminFromHellFlush</code>.
[Boris] October 7, 2008 17:51:58.862
10,
testEndToEndPPDProcessNoReturnReportOrNotification
bad OO
[] October 7, 2008 20:15:23.218
I believe that longest the method name, poor the object oriented design
Do you think the same?
[akuhn] October 8, 2008 6:25:19.333
@anon: I would not say so. Method names serve three (often opposing) purposes
Thus, a long method name can be both good (see #3) and bad (see #2) at the same time.
@boris: I excluded test method names from my analysis, because they are generally much longer than normal names anyway. Why? See above, test methods are never invoked by us, thus we do not need an mnemonic and #2 does not apply. For example, in RExample we use Strings rather than selectors to describe test methods.
[Henry] October 10, 2008 5:46:00.019
Althought the "worst" in my image is
aggregateProbabilityOfImpairmentOfEscapeWithTimeForEndEvent (11)
my favourites though, must be this pair of perfect 10's:
getCurrentExposedItemsFromScenObBeforeBlockageTime
getCurrentExposedItemsFromScenObAtBlockageTime
Why no corresponding After you ask?
The answer is trivial, so I'd rather leave it a mystery :)