strange code in RBRefactoringTest

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

strange code in RBRefactoringTest

demarey
hi,

Does anyone knows if there is a particular reason to write this kind of code (snippet from RBRefactoringTest>>setUp

        assoc := RBRefactoringManager classPool associationAt: #Instance
                                ifAbsent: [RBRefactoringManager classPool associationAt: 'Instance'].
        manager := assoc value.

Thanks,
Christophe
Reply | Threaded
Open this post in threaded view
|

Re: strange code in RBRefactoringTest

Guillermo Polito
I'd say that it looks like a "bug ward". But I think the system should not contain right now classpools with string keys. They should all be symbols.

(Smalltalk allClasses gather: [ :class | class classPool keys ])
select: [ :k | k isSymbol not ]

should be an empty collection.

So you probably can replace those three lines by:

manager := Instance.

?

Guille

El mié., 27 de may. de 2015 a la(s) 9:46 a. m., Christophe Demarey <[hidden email]> escribió:
hi,

Does anyone knows if there is a particular reason to write this kind of code (snippet from RBRefactoringTest>>setUp

        assoc := RBRefactoringManager classPool associationAt: #Instance
                                ifAbsent: [RBRefactoringManager classPool associationAt: 'Instance'].
        manager := assoc value.

Thanks,
Christophe
Reply | Threaded
Open this post in threaded view
|

Re: strange code in RBRefactoringTest

Marcus Denker-4
In reply to this post by demarey

> On 27 May 2015, at 09:46, Christophe Demarey <[hidden email]> wrote:
>
> hi,
>
> Does anyone knows if there is a particular reason to write this kind of code (snippet from RBRefactoringTest>>setUp
>
> assoc := RBRefactoringManager classPool associationAt: #Instance
> ifAbsent: [RBRefactoringManager classPool associationAt: 'Instance'].
> manager := assoc value.
>

I guess someone wanted to reset the class var without adding a #reset method.

There is #nuke, though:

nuke
        Instance notNil ifTrue: [ Instance release ].
        Instance := nil

maybe the test does not want to call #release?

The reflective API was improved in the meantime, you can just do

        RBRefactoringManagerclassVarNamed: ‘Instance' put: nil.


        Marcus
Reply | Threaded
Open this post in threaded view
|

Re: strange code in RBRefactoringTest

demarey

Le 27 mai 2015 à 09:55, Marcus Denker a écrit :

>
>> On 27 May 2015, at 09:46, Christophe Demarey <[hidden email]> wrote:
>>
>> hi,
>>
>> Does anyone knows if there is a particular reason to write this kind of code (snippet from RBRefactoringTest>>setUp
>>
>> assoc := RBRefactoringManager classPool associationAt: #Instance
>> ifAbsent: [RBRefactoringManager classPool associationAt: 'Instance'].
>> manager := assoc value.
>>
>
> I guess someone wanted to reset the class var without adding a #reset method.
>
> There is #nuke, though:
>
> nuke
> Instance notNil ifTrue: [ Instance release ].
> Instance := nil
>
> maybe the test does not want to call #release?
>
> The reflective API was improved in the meantime, you can just do
>
> RBRefactoringManagerclassVarNamed: ‘Instance' put: nil.
>
>
> Marcus

ok, thanks

smime.p7s (5K) Download Attachment