The Artima Developer Community
Sponsored Link

Agile Buzz Forum
I'll take an "S" Vanna

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
I'll take an "S" Vanna Posted: Feb 16, 2005 6:37 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: I'll take an "S" Vanna
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
As I was browsing a couple of packages a couple of days ago, I noticed something funny. Nearly all of the classes seemed to begin with the letter S. Me, a real fan of using namespaces to create little "microverses" where you're free to express class names without worrying about semantic clash, and nearly all of my classes start with the same letter. This of course, degenerates searching for a class in an "alphabetical" list to a linear method. So I wrote a little script.

This is blogged in the same vein as Vassili's Just Browsing entry: interesting ways to programatically access your program space.

I used a workspace and concocted the following block (why a block? see here. I've been accused of too freely extending base classes, but I draw the line at printMostPopularLetterWithPercentageToTheTranscript):

showMostPopular := 
		[:pkg | | classes grouped mostPopular | 
		classes := pkg definedClasses.
		grouped := classes groupedBy: [:eachClass | eachClass name first].
		mostPopular := (grouped associations 
					asSortedCollection: [:a :b | a value size < b value size]) last.
		Transcript
			show: ('<1p> <2p>% <3s>' 
						expandMacrosWith: pkg
						with: mostPopular value size / classes size * 100.0
						with: (String with: mostPopular key));
			cr].

Then you can use something like:

showMostPopular value: (Store.Registry packageNamed: 'YourPackageOfInterest'

Or

(Store.Registry allPackages asSortedCollection: [:a :b | a name < b name]) 
	do: [:eachPkg | eachPkg  definedClasses size > 10 ifTrue: [showMostPopular value: eachPkg]]

This second one is fun, because it shows the results for all comparable sized packages in the system. I was kind of amused. There's some obvious ones like WinLooks which of course is going to have 100% W.

Read: I'll take an "S" Vanna

Topic: Hope Diamond mystery solved Previous Topic   Next Topic Topic: Like, Dude

Sponsored Links



Google
  Web Artima.com   

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