The Artima Developer Community
Sponsored Link

Agile Buzz Forum
More Things to Count

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
More Things to Count Posted: Oct 7, 2008 11:42 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: More Things to Count
Feed Title: Travis Griggs - Blog
Feed URL: http://www.cincomsmalltalk.com/rssBlog/travis-rss.xml
Feed Description: This TAG Line is Extra
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Travis Griggs - Blog

Advertisement

Here's another interesting query. I put it together to prove or disprove a hypothesis of mine. I'll share it first, then the hypothesis, and whether it was proved or disproved.

The Query

bag := Bag new.
bundle := Store.Registry bundleNamed: 'Base VisualWorks'.
bundle leafItems
do:
[:pkg |
pkg compiledMethods
do:
[:each | each resourceType ifNil: [each messagesDo: [:selector | bag add: selector]]]].
bag contents associations sorted: [:a :b | a value > b value]

What does it do? It counts how many times in a given body of code (in this case, the base bundle VisualWorks), you've indicated you want to send a method. It filters out any methods that have a tag in them, because these are auto generated, and not indicative of what messages the programmer is working with themselves.

Hypothesis

My basic theory, is that there's certain methods that I tend to spend more time pondering whether we got the name right, or the model right. It seems plausible that those methods we use the most, are those we give the most consideration to.

The one that I shake my head every single time I have to use it is the

#someInaneReducedSentenceFormat >> 'A string trying to help a user gain greater enlightenment' << #anArbitrarilyChosenCategorizingCatalogID

And I don't get too excited every time I use #expandMacrosWith:with:with:. Is my frustration born out by how often I use them?

Findings

If I run the top query and grab the first 10 off the list, I get:

Method Count
+ 5822
== 5595
= 3719
new 3493
- 2865
at: 2610
@ 2487
>> 2405
<< 2401
#at:put: 2282

Not too many surprises there I guess. I was actually surprised to find >> and << in the top 10. But then, I don't spend that much time in the Base Bundle. I do some, but where I spend a lot of time is in the Tools-IDE bundle. That's my world. Rerunning for that bundle...

Method Count
<< 1827
>> 1816
new 1657
isNil 1040
= 852
do: 816
value 771
size 745
== 739
nextPutAll: 596

So if there's any two selectors I type more than others, it's the >> and <<. My hypothesis apparently had some merit. And given that I spend more time with those things, I feel justified in spending some time thinking about how it might be better.

It's interesting to reflect on what we create binary selectors for. Pedantically speaking, we could do with none. We could spell everything out in prosy semantics. We could use plus: and minus:. But pragmatically, we use the binary selectors as syntactic sugar, usually to reduce the number of characters we type for high frequency one argument keyword selectors.

An additional twist on this query is to multiply the occurrence by the length of selector. We may have 1000 instances of foo: and only 100 instances of aBigLongSelectorThatGoesOnAndOnAndTakesAWhileToType:. We burned 4000 character calories typing the 1000 foo:'s, but we burnt 5200 on the selector that only showed up 1/10th of the time. If we add that in to our query, the output for the Tools-IDE bundle changes to:

nextPutAll: 6556
isNil 5200
new 4971
expandMacrosWith: 4284
asString 3904
value 3855
<< 3654
>> 3632
selector 3472
notNil 3282

And there's our good friend, #expandMacrosWith:, coming in at number 4. What a surprise. Not.

 

Read: More Things to Count

Topic: Thinly Sliced: Monticello2 at Smalltalk Solutions Previous Topic   Next Topic Topic: Rock Meets a Hard Place

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use