FW: Method categories, was: Re: How I wasted one our of my time :
-)
Norton, Chris
chrisn at Kronos.com
Fri Jun 16 14:20:09 UTC 2000
Somehow my post didn't seem to get through the first time...
> -----Original Message-----
> From: Norton, Chris
> Sent: Thursday, June 15, 2000 2:32 PM
> To: 'squeak at cs.uiuc.edu'
> Subject: RE: Method categories, was: Re: How I wasted one our of my
> time :-)
>
> Hi Stefan, Henrik & friends.
>
> Ever since I started Squeaking, I've been frustrated by its lack of
> documentation and categorization of methods -- especially amongst the base
> classes. In fact, I once spent some serious time cleaning up my image
> (recategorizing everything), but that image got wiped out. Sigh.
>
> I still have an algorithm I wrote back in April '99, that does some nifty
> auto-categorization stuff. It doesn't clean up inconsistency problems
> noted by Stefan (i.e. printOn: appearing in several different categories),
> but it does clean up quite a lot of lazy code.
>
> This algorithm will classify all unclassified instance methods into the
> class's parent's instance method categories.
>
> | aClass list |
> Smalltalk classNames do: [:each |
> aClass := (Smalltalk at: each).
> aClass superclass notNil
> ifTrue:
> [(aClass organization listAtCategoryNamed:
> ClassOrganizer default) do: [:sel |
> list := OrderedCollection new.
> aClass allSuperclasses do: [:cl |
> (cl includesSelector: sel)
> ifTrue:
> [((cl organization
> categoryOfElement: sel) ~= ClassOrganizer default)
> ifTrue:
> [list addLast: (cl organization categoryOfElement: sel)]].
> (list isEmpty)
> ifFalse: [aClass
> organization classify: sel under: list first]]]]]
>
> For example, prior to running this algorithm on my 2.9a image, I see that
> EllipseMorph has 5 methods in its "as yet unclassified" category. After
> running the algorithm, I find that all of the instance methods on
> EllipseMorph are now classified (way cool!).
>
> Unfortunately, I don't have time today to make this work with class
> methods too. But I thought you might be interested in this stuff anyway!
> :-)
>
> Cheers,
>
> ---==> Chris
More information about the Squeak-dev
mailing list
|