[ENH] CategorizeUncategorizedMethods-nk

Norton, Chris chrisn at Kronos.com
Tue Feb 13 17:03:25 UTC 2001


Good idea Ned.

I wrote a script to do this very thing a while back, but never published
it...  Actually, I sorta forgot about it.  ;-)

I've attached it, so you can look it over, if you want.  It only attempts to
recategorize instance methods.

Anyway, I think this is something that should be run on the image
periodically.  IMHO, it will help new programmers understand a bit more
about the purpose of some methods.  It's good to have self documenting code,
but good organization of information is just as important.

I recall thinking, at the time, that perhaps the file-in mechanism should
automatically categorize uncategorized methods.

Cheers,

---==> Chris

PS>  Attached is a change set that can be used to move all methods in the
category 'all' to unclassified.  If you then run my script, the unclassified
methods will go into the, presumably, correct categories.

PPS>  A more challenging task might be to have the browser warn you when you
move a superclass' method to a new category, that subclasses have overridden
this method and "do you want to reclassify the subclass method too?"  :-)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Categorize all unclassified instance methods in your image."

    | aClass list |
    Smalltalk classNames
        do: [:each |
            aClass := (Smalltalk at: each).
            aClass superclass notNil
                ifTrue:
                    [methodsToReclassify := aClass organization
listAtCategoryNamed: ClassOrganizer default.
                    methodsToReclassify
                        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]]]]]

 <<GroupReclassify.cs>> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GroupReclassify.cs
Type: application/octet-stream
Size: 3542 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20010213/5d47070f/GroupReclassify.obj


More information about the Squeak-dev mailing list