[squeak-dev] Re: Two methods sharing source code?
Klaus D. Witzel
klaus.witzel at cobss.com
Thu May 29 15:37:41 UTC 2008
On Thu, 29 May 2008 17:16:32 +0200, Martin Beck wrote:
> Klaus D. Witzel schrieb:
>> On Thu, 29 May 2008 15:39:58 +0200, Martin Beck wrote:
>>
>>> Hi there,
>>> for some reasons, I want to have two methods sharing the same source
>>> code base. So if I change one method within the browser, the other
>>> would change, too.
>> Whenever I want that, I put the method(s) into a Trait and #use: that
>> Trait in the respective classes. Later changing the Trait's method(s)
>> also changes the Trait user's method (traits only recompiles its used
>> methods if they do super send).
>>
> Yupp, I know that, but as my other post indicated, one half of these
> classes or methods are part of the Collection hierarchy, which I of
> course don't want to change... Otherwise, a trait would be a useful
> solution, I agree.
Okay, Traits was meant for the general case ;) If I do the above to
collection (I more often do that to compiler), and I do want the same
interface and the closest possible implementation (=same source code),
then I put this in MyClass class initialization
initialize
"MyClass initialize"
(self recompile: #thisNthat from: DonorClass; organization)
classify: #thisNthat under: #'DonorClass-method'
ditto for each selector (or loop over an array of selectors). And if some
DonorClass method had changed, just select and eval the comment :)
/Klaus
> Martin
>
>
More information about the Squeak-dev
mailing list
|