Fwd: refactoring

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

Fwd: refactoring

Helmut Rohregger
Hi,

because I didn't get response to my question in the beginners list, I
post it here.

Is there an easy way to change instance methods to class methods?
I know it is possible to drag and drop single methods. But I am looking
for the possibility to move 100+ methods at once.

- Helmut

Reply | Threaded
Open this post in threaded view
|

Re: Fwd: refactoring

Eliot Miranda-2
class selectors do: [:s| class class recompile: s from: class. class removeSelector: s]

Eliot (phone)

On Apr 22, 2014, at 11:18 PM, Helmut Rohregger <[hidden email]> wrote:

> Hi,
>
> because I didn't get response to my question in the beginners list, I
> post it here.
>
> Is there an easy way to change instance methods to class methods?
> I know it is possible to drag and drop single methods. But I am looking
> for the possibility to move 100+ methods at once.
>
> - Helmut
>

Reply | Threaded
Open this post in threaded view
|

Re: Fwd: refactoring

Helmut Rohregger
Thanks.

The methods now have been moved to the method dictionary of the
specified class, but don't show up in the method browser. How do I clone
the categories?

- Helmut

Am 23.04.2014 08:22, schrieb Eliot Miranda:

> class selectors do: [:s| class class recompile: s from: class. class removeSelector: s]
>
> Eliot (phone)
>
> On Apr 22, 2014, at 11:18 PM, Helmut Rohregger <[hidden email]> wrote:
>
>> Hi,
>>
>> because I didn't get response to my question in the beginners list, I
>> post it here.
>>
>> Is there an easy way to change instance methods to class methods?
>> I know it is possible to drag and drop single methods. But I am looking
>> for the possibility to move 100+ methods at once.
>>
>> - Helmut
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: Fwd: refactoring

Eliot Miranda-2



On Wed, Apr 23, 2014 at 12:50 AM, Helmut Rohregger <[hidden email]> wrote:
Thanks.

The methods now have been moved to the method dictionary of the
specified class, but don't show up in the method browser. How do I clone
the categories?

hmmm, that'll teach me to write code off the top of my head.  Instead use 
 
class selectors do: [:s| class class copy: s from: class. class removeSelector: s]

See also copyAll:from: in ClassDescription


- Helmut

Am 23.04.2014 08:22, schrieb Eliot Miranda:
> class selectors do: [:s| class class recompile: s from: class. class removeSelector: s]
>
> Eliot (phone)
>
> On Apr 22, 2014, at 11:18 PM, Helmut Rohregger <[hidden email]> wrote:
>
>> Hi,
>>
>> because I didn't get response to my question in the beginners list, I
>> post it here.
>>
>> Is there an easy way to change instance methods to class methods?
>> I know it is possible to drag and drop single methods. But I am looking
>> for the possibility to move 100+ methods at once.
>>
>> - Helmut
>>
>





--
best,
Eliot


Reply | Threaded
Open this post in threaded view
|

Re: refactoring

Andreas Wacknitz
In reply to this post by Helmut Rohregger
Hi Helmut,

Am 23.04.2014 um 08:18 schrieb Helmut Rohregger <[hidden email]>:

> Hi,
>
> because I didn't get response to my question in the beginners list, I
> post it here.
>
> Is there an easy way to change instance methods to class methods?
> I know it is possible to drag and drop single methods. But I am looking
> for the possibility to move 100+ methods at once.
>
> - Helmut
>

Are you really trying to move 100+ methods within a single class?
If so that sounds utterly wrong. And moving from the instance side to the class side is even worse.
This smells like putting a single class around your old non-OO code.
If you don’t have REALLY good reasons to have such a number of methods in a class you should
consider to refactor the class into several classes.
This wouldn’t prevent you from having the problem to move methods around but would lessen the pain.

Regards,
Andreas


Reply | Threaded
Open this post in threaded view
|

Re: Fwd: refactoring

Helmut Rohregger
In reply to this post by Eliot Miranda-2
That helped! Thank you Eliot!

Thats the code I wrote, which moved all methods from one class into
another...

moveFrom: srcClass to: destClass
   | categories |
   categories := (srcClass organization) categories.
   1 to: categories size do: [ :index |
      destClass copyCategory: (categories at: index) from: srcClass.
      srcClass removeCategory: (categories at: index).
   ].


- Helmut

Am 23.04.2014 18:37, schrieb Eliot Miranda:

>
>
>
> On Wed, Apr 23, 2014 at 12:50 AM, Helmut Rohregger
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     Thanks.
>
>     The methods now have been moved to the method dictionary of the
>     specified class, but don't show up in the method browser. How do I clone
>     the categories?
>
>
> hmmm, that'll teach me to write code off the top of my head.  Instead use
>  
> class selectors do: [:s| class class copy: s from: class. class
> removeSelector: s]
>
> See also copyAll:from: in ClassDescription
>
>
>     - Helmut
>
>     Am 23.04.2014 08:22, schrieb Eliot Miranda:
>     > class selectors do: [:s| class class recompile: s from: class.
>     class removeSelector: s]
>     >
>     > Eliot (phone)
>     >
>     > On Apr 22, 2014, at 11:18 PM, Helmut Rohregger
>     <[hidden email] <mailto:[hidden email]>> wrote:
>     >
>     >> Hi,
>     >>
>     >> because I didn't get response to my question in the beginners list, I
>     >> post it here.
>     >>
>     >> Is there an easy way to change instance methods to class methods?
>     >> I know it is possible to drag and drop single methods. But I am
>     looking
>     >> for the possibility to move 100+ methods at once.
>     >>
>     >> - Helmut
>     >>
>     >
>
>
>
>
>
> --
> best,
> Eliot
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: refactoring

Helmut Rohregger
In reply to this post by Andreas Wacknitz
Hi Andreas,

thanks for your response.

This is just a test class, where every single method is a test case. I
implemented this class when I started to learn Squeak and implemented
this test cases by mistake at the instance side of the test class...

- Helmut

Am 23.04.2014 18:51, schrieb Andreas Wacknitz:

> Hi Helmut,
>
> Am 23.04.2014 um 08:18 schrieb Helmut Rohregger <[hidden email]>:
>
>> Hi,
>>
>> because I didn't get response to my question in the beginners list, I
>> post it here.
>>
>> Is there an easy way to change instance methods to class methods?
>> I know it is possible to drag and drop single methods. But I am looking
>> for the possibility to move 100+ methods at once.
>>
>> - Helmut
>>
>
> Are you really trying to move 100+ methods within a single class?
> If so that sounds utterly wrong. And moving from the instance side to the class side is even worse.
> This smells like putting a single class around your old non-OO code.
> If you don’t have REALLY good reasons to have such a number of methods in a class you should
> consider to refactor the class into several classes.
> This wouldn’t prevent you from having the problem to move methods around but would lessen the pain.
>
> Regards,
> Andreas
>
>


Reply | Threaded
Open this post in threaded view
|

Re: refactoring

Frank Shearar-3
That confuses me, because people usually implement their tests as
instance methods of a TestCase subclass.

I wouldn't be surprised if writing your test cases as class-side
methods didn't break something in tooling that might well expect to
see instance methods.

frank

On 23 April 2014 20:09, Helmut Rohregger <[hidden email]> wrote:

> Hi Andreas,
>
> thanks for your response.
>
> This is just a test class, where every single method is a test case. I
> implemented this class when I started to learn Squeak and implemented
> this test cases by mistake at the instance side of the test class...
>
> - Helmut
>
> Am 23.04.2014 18:51, schrieb Andreas Wacknitz:
>> Hi Helmut,
>>
>> Am 23.04.2014 um 08:18 schrieb Helmut Rohregger <[hidden email]>:
>>
>>> Hi,
>>>
>>> because I didn't get response to my question in the beginners list, I
>>> post it here.
>>>
>>> Is there an easy way to change instance methods to class methods?
>>> I know it is possible to drag and drop single methods. But I am looking
>>> for the possibility to move 100+ methods at once.
>>>
>>> - Helmut
>>>
>>
>> Are you really trying to move 100+ methods within a single class?
>> If so that sounds utterly wrong. And moving from the instance side to the class side is even worse.
>> This smells like putting a single class around your old non-OO code.
>> If you don’t have REALLY good reasons to have such a number of methods in a class you should
>> consider to refactor the class into several classes.
>> This wouldn’t prevent you from having the problem to move methods around but would lessen the pain.
>>
>> Regards,
>> Andreas
>>
>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: refactoring

Helmut Rohregger
To clarify things: I am writing a squeak byte code interpreter in Java,
which is still in experimental stage. To test my interpreter, I have
written test cases in squeak, which get executed in my interpreter...

- Helmut

Am 24.04.2014 11:54, schrieb Frank Shearar:

> That confuses me, because people usually implement their tests as
> instance methods of a TestCase subclass.
>
> I wouldn't be surprised if writing your test cases as class-side
> methods didn't break something in tooling that might well expect to
> see instance methods.
>
> frank
>
> On 23 April 2014 20:09, Helmut Rohregger <[hidden email]> wrote:
>> Hi Andreas,
>>
>> thanks for your response.
>>
>> This is just a test class, where every single method is a test case. I
>> implemented this class when I started to learn Squeak and implemented
>> this test cases by mistake at the instance side of the test class...
>>
>> - Helmut
>>
>> Am 23.04.2014 18:51, schrieb Andreas Wacknitz:
>>> Hi Helmut,
>>>
>>> Am 23.04.2014 um 08:18 schrieb Helmut Rohregger <[hidden email]>:
>>>
>>>> Hi,
>>>>
>>>> because I didn't get response to my question in the beginners list, I
>>>> post it here.
>>>>
>>>> Is there an easy way to change instance methods to class methods?
>>>> I know it is possible to drag and drop single methods. But I am looking
>>>> for the possibility to move 100+ methods at once.
>>>>
>>>> - Helmut
>>>>
>>>
>>> Are you really trying to move 100+ methods within a single class?
>>> If so that sounds utterly wrong. And moving from the instance side to the class side is even worse.
>>> This smells like putting a single class around your old non-OO code.
>>> If you don’t have REALLY good reasons to have such a number of methods in a class you should
>>> consider to refactor the class into several classes.
>>> This wouldn’t prevent you from having the problem to move methods around but would lessen the pain.
>>>
>>> Regards,
>>> Andreas
>>>
>>>
>>
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: refactoring

Nicolai Hess
Hi Helmut,


2014-04-26 16:40 GMT+02:00 Helmut Rohregger <[hidden email]>:
To clarify things: I am writing a squeak byte code interpreter in Java,
which is still in experimental stage. To test my interpreter, I have
written test cases in squeak, which get executed in my interpreter...


I once ported squeaks vm code from C to java.
(I did not develope my own interpreter most of the initial code was
copy and pasted and (manually) translated to valid javacode.
(And heavily restructured afterwards.))

Maybe your are interested in that code, even though you
are developing your own and don't want to port the exising one.

The code is pretty old (6-8 years!), but it can load and execute a squeak 3.10 image


regards
Nicolai




 

- Helmut

Am <a href="tel:24.04.2014%2011" value="+12404201411" target="_blank">24.04.2014 11:54, schrieb Frank Shearar:
> That confuses me, because people usually implement their tests as
> instance methods of a TestCase subclass.
>
> I wouldn't be surprised if writing your test cases as class-side
> methods didn't break something in tooling that might well expect to
> see instance methods.
>
> frank
>
> On 23 April 2014 20:09, Helmut Rohregger <[hidden email]> wrote:
>> Hi Andreas,
>>
>> thanks for your response.
>>
>> This is just a test class, where every single method is a test case. I
>> implemented this class when I started to learn Squeak and implemented
>> this test cases by mistake at the instance side of the test class...
>>
>> - Helmut
>>
>> Am 23.04.2014 18:51, schrieb Andreas Wacknitz:
>>> Hi Helmut,
>>>
>>> Am 23.04.2014 um 08:18 schrieb Helmut Rohregger <[hidden email]>:
>>>
>>>> Hi,
>>>>
>>>> because I didn't get response to my question in the beginners list, I
>>>> post it here.
>>>>
>>>> Is there an easy way to change instance methods to class methods?
>>>> I know it is possible to drag and drop single methods. But I am looking
>>>> for the possibility to move 100+ methods at once.
>>>>
>>>> - Helmut
>>>>
>>>
>>> Are you really trying to move 100+ methods within a single class?
>>> If so that sounds utterly wrong. And moving from the instance side to the class side is even worse.
>>> This smells like putting a single class around your old non-OO code.
>>> If you don’t have REALLY good reasons to have such a number of methods in a class you should
>>> consider to refactor the class into several classes.
>>> This wouldn’t prevent you from having the problem to move methods around but would lessen the pain.
>>>
>>> Regards,
>>> Andreas
>>>
>>>
>>
>>
>





Reply | Threaded
Open this post in threaded view
|

Re: refactoring

Helmut Rohregger
Hi Nicolai,

my squeak bytecode interpreter is in "advanced" experimental stage ;)

Its an AST interpreter using Oracle's Truffle Framework, which is part of the Graal project (http://openjdk.java.net/projects/graal/).

However, I am interested in your code. Maybe I'll find something useful, I can use for my project. So, thank you for you offer...

- Helmut

Am 15.05.2014 17:41, schrieb Nicolai Hess:
Hi Helmut,


2014-04-26 16:40 GMT+02:00 Helmut Rohregger <[hidden email]>:
To clarify things: I am writing a squeak byte code interpreter in Java,
which is still in experimental stage. To test my interpreter, I have
written test cases in squeak, which get executed in my interpreter...


I once ported squeaks vm code from C to java.
(I did not develope my own interpreter most of the initial code was
copy and pasted and (manually) translated to valid javacode.
(And heavily restructured afterwards.))

Maybe your are interested in that code, even though you
are developing your own and don't want to port the exising one.

The code is pretty old (6-8 years!), but it can load and execute a squeak 3.10 image


regards
Nicolai




 

- Helmut

Am <a moz-do-not-send="true" href="tel:24.04.2014%2011" value="+12404201411" target="_blank">24.04.2014 11:54, schrieb Frank Shearar:
> That confuses me, because people usually implement their tests as
> instance methods of a TestCase subclass.
>
> I wouldn't be surprised if writing your test cases as class-side
> methods didn't break something in tooling that might well expect to
> see instance methods.
>
> frank
>
> On 23 April 2014 20:09, Helmut Rohregger <[hidden email]> wrote:
>> Hi Andreas,
>>
>> thanks for your response.
>>
>> This is just a test class, where every single method is a test case. I
>> implemented this class when I started to learn Squeak and implemented
>> this test cases by mistake at the instance side of the test class...
>>
>> - Helmut
>>
>> Am 23.04.2014 18:51, schrieb Andreas Wacknitz:
>>> Hi Helmut,
>>>
>>> Am 23.04.2014 um 08:18 schrieb Helmut Rohregger <[hidden email]>:
>>>
>>>> Hi,
>>>>
>>>> because I didn't get response to my question in the beginners list, I
>>>> post it here.
>>>>
>>>> Is there an easy way to change instance methods to class methods?
>>>> I know it is possible to drag and drop single methods. But I am looking
>>>> for the possibility to move 100+ methods at once.
>>>>
>>>> - Helmut
>>>>
>>>
>>> Are you really trying to move 100+ methods within a single class?
>>> If so that sounds utterly wrong. And moving from the instance side to the class side is even worse.
>>> This smells like putting a single class around your old non-OO code.
>>> If you don’t have REALLY good reasons to have such a number of methods in a class you should
>>> consider to refactor the class into several classes.
>>> This wouldn’t prevent you from having the problem to move methods around but would lessen the pain.
>>>
>>> Regards,
>>> Andreas
>>>
>>>
>>
>>
>