The tedious split between class and instance?

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

The tedious split between class and instance?

Tim Mackinnon
The more I use Pharo again - the more it strikes me how tedious it is to have to flip between instance and class side definitions.

For example - if I create a new class with an instance variable, and then in my class constructor method decide that it would be handy to do:

^self new children: items; yourself

But I don’t yet have the #children: method - if I select the create accessors refactoring (while still looking at my class method) - it does nothing because I have an instance variable not a class variable. So I have to switch to the instance side, to use this refactoring and then flip back to writing my class method.

This is really tedious - we really should find a better way to do this, as it eats away at your programming flow. It’s not the language - its the tools…

Tim
Reply | Threaded
Open this post in threaded view
|

Re: The tedious split between class and instance?

EstebanLM
+1
it would be really useful to have a refactoring “make creator with instance vars”, to allow you to pick inst vars and do something like:

Blah class>>children: aCollection
        ^ self basicNew
                initializeChildren: aCollection;
                yourself

Blah>>initializeChildren: aCollection
        children := aCollection.
        self initialize.

that would solve all the problem and would be also a nice way to promote a convention on how to do the creation properly :)

Esteban

On 09 Aug 2014, at 16:29, Tim Mackinnon <[hidden email]> wrote:

> The more I use Pharo again - the more it strikes me how tedious it is to have to flip between instance and class side definitions.
>
> For example - if I create a new class with an instance variable, and then in my class constructor method decide that it would be handy to do:
>
> ^self new children: items; yourself
>
> But I don’t yet have the #children: method - if I select the create accessors refactoring (while still looking at my class method) - it does nothing because I have an instance variable not a class variable. So I have to switch to the instance side, to use this refactoring and then flip back to writing my class method.
>
> This is really tedious - we really should find a better way to do this, as it eats away at your programming flow. It’s not the language - its the tools…
>
> Tim