ClassOrganizer and classifyAllUnclassfied

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ClassOrganizer and classifyAllUnclassfied

patrick.rein
Hi all,

while going through categories I naturally came by the source code for categorizing all uncategorized messages through the context menu in the Browser (Browser>>#categorizeAllUncategorizedMethods). I found that that method implemented the logic of classifying methods which I found odd as this sounds like something the class organizer should take care of. Thus, I rewrote the two classes to the code below:

Browser>>#categorizeAllUncategorizedMethods
        "Categorize methods by looking in parent classes for a method category."

        self classOrMetaClassOrganizer classifyAllUnclassified.
        self changed: #messageCategoryList

ClassOrganizer>>#classifyAllUnclassified

        | organizers |
        organizers := self subject withAllSuperclasses collect: [:ea | ea organization].
        (self listAtCategoryNamed: ClassOrganizer default) do: [:sel | | found |
                found := (organizers collect: [ :org | org categoryOfElement: sel])
                        detect: [:ea | ea ~= ClassOrganizer default and: [ ea ~= nil]]
                        ifNone: [].
                found ifNotNil: [self classify: sel under: found]].


Does anyone have any opinion on that? I really prefer that version but I wanted to check first if there is a good reason not to have this in the Organizers.

Bests
Patrick

P.S.: I also just noticed a weird inconsistency in the naming scheme between categorizing (Browser) and classifying (Organizer).

Reply | Threaded
Open this post in threaded view
|

Re: ClassOrganizer and classifyAllUnclassfied

marcel.taeumel
Hi, there.

Yes, ClassOrganizer knows about classes and thus also about
#withAllSuperclasses. Putting the #classifyAllUnclassified code into
ClassOrganizer improves the support for tests and scripts.

Yet, the name "classifyAllUnclassified" is ambiguous. Why not keep the name
"categorizeAllUncategorizedMethods"? It is an organizer that manages
categories. What about "categorizeAllUncategorized"? Such a method could
exist for other organizers as well, using some other rule.

In general: +1

Best,
Marcel


patrick.rein wrote

> Hi all,
>
> while going through categories I naturally came by the source code for
> categorizing all uncategorized messages through the context menu in the
> Browser (Browser>>#categorizeAllUncategorizedMethods). I found that that
> method implemented the logic of classifying methods which I found odd as
> this sounds like something the class organizer should take care of. Thus,
> I rewrote the two classes to the code below:
>
> Browser>>#categorizeAllUncategorizedMethods
> "Categorize methods by looking in parent classes for a method category."
>
> self classOrMetaClassOrganizer classifyAllUnclassified.
> self changed: #messageCategoryList
>
> ClassOrganizer>>#classifyAllUnclassified
>
> | organizers |
> organizers := self subject withAllSuperclasses collect: [:ea | ea
> organization].
> (self listAtCategoryNamed: ClassOrganizer default) do: [:sel | | found |
> found := (organizers collect: [ :org | org categoryOfElement: sel])
> detect: [:ea | ea ~= ClassOrganizer default and: [ ea ~= nil]]
> ifNone: [].
> found ifNotNil: [self classify: sel under: found]].
>
>
> Does anyone have any opinion on that? I really prefer that version but I
> wanted to check first if there is a good reason not to have this in the
> Organizers.
>
> Bests
> Patrick
>
> P.S.: I also just noticed a weird inconsistency in the naming scheme
> between categorizing (Browser) and classifying (Organizer).





--
Sent from: http://forum.world.st/Squeak-Dev-f45488.html