Tim M | 17 May 03:21
Picon

Easy way to override a method?

Is there an easy way in Squeak to override a method?

I have created a subclass of a class, and am viewing my subclass in a hierarchy 
browser. I have clicked on the superclass in the browser and am browsing 
methods to see what I need to override.

Having discovered a method that I want to override - I was hoping I could 
right click on that method and select Refactor|Override - but its not there 
(it is in Dolphin). Failing this I tried drag and drop - but that seems to 
just move the method (I held the Control key while dragging but I guess thats 
a Dolphin and a windows thing).

Is there some way to easily and quickly do this without having to cut and 
paste?

Tim
Herbert König | 17 May 08:57
Picon

Re: Easy way to override a method?

Hello Tim,

TM> Is there an easy way in Squeak to override a method?

if I don't misunderstand you, you just redefine it in your subclass?

TM> (it is in Dolphin). Failing this I tried drag and drop - but that seems to
TM> just move the method (I held the Control key while dragging but I guess thats
TM> a Dolphin and a windows thing).

RB uses the shift key to copy a method into another class instead of
moving it. Other refactorings are push up, push down moving the method
down to every subclass.

--

-- 
Cheers,

Herbert   
Tim M | 17 May 14:26
Picon

Re: Easy way to override a method?

Hi Herbert,

> if I don't misunderstand you, you just redefine it in your subclass?

Yes but its a nuisance to copy the method signature, click on the class below, 
click on a method (or the as yes undefined category), and then paste the 
signature and then enter by override.

I was hoping that there was something like in dolphin - browse my subclass 
but enable show inherited methods - select the inehrited method, right click 
and pick Refactoring | Override - this then does then creates me a template 
that overrides.

> RB uses the shift key to copy a method into another class instead of
> moving it. Other refactorings are push up, push down moving the method
> down to every subclass.

The shift key wasn't one I thought of - that is a reasonable workaround if 
a bit mousy. Maybe if I get better at Squeak I will work out how to add a 
keyboard shortcut.

Thanks for the tips.

Tim
Giovanni Corriga | 17 May 14:36
Gravatar

Re: Re: Easy way to override a method?

Tim M ha scritto:
> Hi Herbert,
> 
>> if I don't misunderstand you, you just redefine it in your subclass?
> 
> Yes but its a nuisance to copy the method signature, click on the class 
> below, click on a method (or the as yes undefined category), and then 
> paste the signature and then enter by override.
> 
> I was hoping that there was something like in dolphin - browse my 
> subclass but enable show inherited methods - select the inehrited 
> method, right click and pick Refactoring | Override - this then does 
> then creates me a template that overrides.

Using eCompletion, if you know which method to override you can simply 
start typing the first few letters of the selector, then press 
CTRL+space and select the method from the popup window.

	Giovanni
Matthew Fulmer | 17 May 20:24
Picon

Re: Re: Easy way to override a method?

On Sat, May 17, 2008 at 12:26:50PM +0000, Tim M wrote:
> Hi Herbert,
>
>> if I don't misunderstand you, you just redefine it in your subclass?
>
> Yes but its a nuisance to copy the method signature, click on the class 
> below, click on a method (or the as yes undefined category), and then paste 
> the signature and then enter by override.
>
> I was hoping that there was something like in dolphin - browse my subclass 
> but enable show inherited methods - select the inehrited method, right 
> click and pick Refactoring | Override - this then does then creates me a 
> template that overrides.

to show a class with some of it's inherited methods, use the
protocol browser (select a class, and alt-P). When you save a
method in the protocol browser, it asks you which class to save
it under, if I remember correctly.

--

-- 
Matthew Fulmer -- http://mtfulmer.wordpress.com/
Scott Wallace | 17 May 21:42

Re: Re: Easy way to override a method?

On May 17, 2008, at 5:26 AM, Tim M wrote:

> ...Yes but its a nuisance to copy the method signature, click on the  
> class below, click on a method (or the as yes undefined category),  
> and then paste the signature and then enter by override.
>

I'm surprised no one has mentioned the "copy up or copy down..."  
feature, available in the "more..." branch of the selector-list menu  
of any browser or message-list of most versions of Squeak since March  
2001.

-- sw

Gmane