[bloc] why redefining new is not enough?

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

[bloc] why redefining new is not enough?

stepharo
BlElement class>>basicNew
     "Redefined to set the space of the element"

     ^ super basicNew basicSpace: BlUniverse default runningSpace

why redefining new is not enough?

Ok now back to the mooc videos :(


Reply | Threaded
Open this post in threaded view
|

Re: [bloc] why redefining new is not enough?

EstebanLM
this is bad… redefining basicNew should not be done, never, never, never.
that’s why we have new and basicNew :)

Esteban

> On 25 Feb 2016, at 09:52, stepharo <[hidden email]> wrote:
>
> BlElement class>>basicNew
>    "Redefined to set the space of the element"
>
>    ^ super basicNew basicSpace: BlUniverse default runningSpace
>
> why redefining new is not enough?
>
> Ok now back to the mooc videos :(
>
>


Reply | Threaded
Open this post in threaded view
|

Re: [bloc] why redefining new is not enough?

Pharo Smalltalk Developers mailing list

> On 25 févr. 2016, at 11:49, Esteban Lorenzano <[hidden email]> wrote:
>
> this is bad… redefining basicNew should not be done, never, never, never.
why ?

> that’s why we have new and basicNew :)

the space may be needed during #initialize.
this is why the initialization of the space is done in
basicNew.
But ok, we will fix that.
Thanks
Alain

>
> Esteban
>
>> On 25 Feb 2016, at 09:52, stepharo <[hidden email]> wrote:
>>
>> BlElement class>>basicNew
>>   "Redefined to set the space of the element"
>>
>>   ^ super basicNew basicSpace: BlUniverse default runningSpace
>>
>> why redefining new is not enough?
>>
>> Ok now back to the mooc videos :(
>>
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: [bloc] why redefining new is not enough?

Clément Béra
Hi,

when redefining new you don't have to use super:

BlElement class>>new
    ^ self basicNew 
        basicSpace: BlUniverse default runningSpace;
        initialize;
        yourself

IMO that's a better practice that redefining basicNew.

Usually basicNew is only redefined when you cannot instantiate the objects using the normal API because it is not supported by the runtime (SmallInteger, Context, etc.)



2016-02-25 12:33 GMT+01:00 Alain Plantec via Pharo-dev <[hidden email]>:


---------- Message transféré ----------
From: Alain Plantec <[hidden email]>
To: Pharo Development List <[hidden email]>
Cc: 
Date: Thu, 25 Feb 2016 12:37:59 +0100
Subject: Re: [Pharo-dev] [bloc] why redefining new is not enough?

> On 25 févr. 2016, at 11:49, Esteban Lorenzano <[hidden email]> wrote:
>
> this is bad… redefining basicNew should not be done, never, never, never.
why ?

> that’s why we have new and basicNew :)

the space may be needed during #initialize.
this is why the initialization of the space is done in
basicNew.
But ok, we will fix that.
Thanks
Alain

>
> Esteban
>
>> On 25 Feb 2016, at 09:52, stepharo <[hidden email]> wrote:
>>
>> BlElement class>>basicNew
>>   "Redefined to set the space of the element"
>>
>>   ^ super basicNew basicSpace: BlUniverse default runningSpace
>>
>> why redefining new is not enough?
>>
>> Ok now back to the mooc videos :(
>>
>>
>
>




Reply | Threaded
Open this post in threaded view
|

Re: [bloc] why redefining new is not enough?

Stephan Eggermont-3
In reply to this post by Pharo Smalltalk Developers mailing list
On 25-02-16 12:31, Alain Plantec via Pharo-dev wrote:
 >the space may be needed during #initialize.

I would strongly advice against that. That makes it untestable

Stephan


Reply | Threaded
Open this post in threaded view
|

Re: [bloc] why redefining new is not enough?

EstebanLM
In reply to this post by Pharo Smalltalk Developers mailing list

On 25 Feb 2016, at 12:32, Alain Plantec via Pharo-dev <[hidden email]> wrote:


From: Alain Plantec <[hidden email]>
Subject: Re: [Pharo-dev] [bloc] why redefining new is not enough?
Date: 25 February 2016 at 12:37:59 GMT+1
To: Pharo Development List <[hidden email]>



On 25 févr. 2016, at 11:49, Esteban Lorenzano <[hidden email]> wrote:

this is bad… redefining basicNew should not be done, never, never, never.
why ?

well… is not forbidden, of course… 
but many frameworks use basicNew as a way of obtain *explicitly* non-initialized objects (voyage does that, for instance). 


that’s why we have new and basicNew :)

the space may be needed during #initialize.
this is why the initialization of the space is done in
basicNew.
But ok, we will fix that.

you can define new as: 

new 
^ self basicNew 
basicSpace: BlUniverse default runningSpace;
initialize;
yourself

that’s perfectly fine :)

other possibility is to lazy initialise space with the default universe. 

Esteban

Thanks
Alain


Esteban

On 25 Feb 2016, at 09:52, stepharo <[hidden email]> wrote:

BlElement class>>basicNew
 "Redefined to set the space of the element"

 ^ super basicNew basicSpace: BlUniverse default runningSpace

why redefining new is not enough?

Ok now back to the mooc videos :(









Reply | Threaded
Open this post in threaded view
|

Re: [bloc] why redefining new is not enough?

EstebanLM
In reply to this post by Clément Béra

On 25 Feb 2016, at 13:34, Clément Bera <[hidden email]> wrote:

Hi,

when redefining new you don't have to use super:

BlElement class>>new
    ^ self basicNew 
        basicSpace: BlUniverse default runningSpace;
        initialize;
        yourself

IMO that's a better practice that redefining basicNew.

I just sent the same example ;)


Usually basicNew is only redefined when you cannot instantiate the objects using the normal API because it is not supported by the runtime (SmallInteger, Context, etc.)



2016-02-25 12:33 GMT+01:00 Alain Plantec via Pharo-dev <[hidden email]>:


---------- Message transféré ----------
From: Alain Plantec <[hidden email]>
To: Pharo Development List <[hidden email]>
Cc: 
Date: Thu, 25 Feb 2016 12:37:59 +0100
Subject: Re: [Pharo-dev] [bloc] why redefining new is not enough?

> On 25 févr. 2016, at 11:49, Esteban Lorenzano <[hidden email]> wrote:
>
> this is bad… redefining basicNew should not be done, never, never, never.
why ?

> that’s why we have new and basicNew :)

the space may be needed during #initialize.
this is why the initialization of the space is done in
basicNew.
But ok, we will fix that.
Thanks
Alain

>
> Esteban
>
>> On 25 Feb 2016, at 09:52, stepharo <[hidden email]> wrote:
>>
>> BlElement class>>basicNew
>>   "Redefined to set the space of the element"
>>
>>   ^ super basicNew basicSpace: BlUniverse default runningSpace
>>
>> why redefining new is not enough?
>>
>> Ok now back to the mooc videos :(
>>
>>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: [bloc] why redefining new is not enough?

Pharo Smalltalk Developers mailing list
In reply to this post by EstebanLM


well… is not forbidden, of course… 
but many frameworks use basicNew as a way of obtain *explicitly* non-initialized objects (voyage does that, for instance). 

ok



that’s why we have new and basicNew :)

the space may be needed during #initialize.
this is why the initialization of the space is done in
basicNew.
But ok, we will fix that.

you can define new as: 

new 
^ self basicNew 
basicSpace: BlUniverse default runningSpace;
initialize;
yourself

that’s perfectly fine :)

this is how I intended to fix it.


other possibility is to lazy initialise space with the default universe. 

maybe, I don’t know.


thanks
Alain




Esteban

Thanks
Alain


Esteban

On 25 Feb 2016, at 09:52, stepharo <[hidden email]> wrote:

BlElement class>>basicNew
 "Redefined to set the space of the element"

 ^ super basicNew basicSpace: BlUniverse default runningSpace

why redefining new is not enough?

Ok now back to the mooc videos :(










Reply | Threaded
Open this post in threaded view
|

Re: [bloc] why redefining new is not enough?

Pharo Smalltalk Developers mailing list
In reply to this post by Stephan Eggermont-3

Hello Stephan,
> On 25 Feb 2016, at 13:30, Stephan Eggermont <[hidden email]> wrote:
>
> On 25-02-16 12:31, Alain Plantec via Pharo-dev wrote:
> >the space may be needed during #initialize.
>
> I would strongly advice against that. That makes it untestable

interesting.
can you elaborate ?
thanks

Alain


>
> Stephan
>
>


Reply | Threaded
Open this post in threaded view
|

Re: [bloc] why redefining new is not enough?

Aliaksei Syrel
In reply to this post by stepharo

Well, it is not *important* for design what method is redefined new or basicNew in order to set space. My question is why do we need at all to set space? It means that element created (not added) while spaceA is running can not be used in or added to spaceB.
The only reason that I know is a possibility to add global event listener to space while initializing an element. This must be fixed by having lazy addition of global event listeners.

On Feb 25, 2016 9:55 AM, "stepharo" <[hidden email]> wrote:
BlElement class>>basicNew
    "Redefined to set the space of the element"

    ^ super basicNew basicSpace: BlUniverse default runningSpace

why redefining new is not enough?

Ok now back to the mooc videos :(


Reply | Threaded
Open this post in threaded view
|

Re: [bloc] why redefining new is not enough?

Aliaksei Syrel

An we need NullSpace to be default value.

On Feb 25, 2016 2:06 PM, "Aliaksei Syrel" <[hidden email]> wrote:

Well, it is not *important* for design what method is redefined new or basicNew in order to set space. My question is why do we need at all to set space? It means that element created (not added) while spaceA is running can not be used in or added to spaceB.
The only reason that I know is a possibility to add global event listener to space while initializing an element. This must be fixed by having lazy addition of global event listeners.

On Feb 25, 2016 9:55 AM, "stepharo" <[hidden email]> wrote:
BlElement class>>basicNew
    "Redefined to set the space of the element"

    ^ super basicNew basicSpace: BlUniverse default runningSpace

why redefining new is not enough?

Ok now back to the mooc videos :(


Reply | Threaded
Open this post in threaded view
|

Re: [bloc] why redefining new is not enough?

Stephan Eggermont-3
In reply to this post by Pharo Smalltalk Developers mailing list
On 25-02-16 14:00, Alain Plantec via Pharo-dev wrote:
 >interesting.
 >can you elaborate ?

Basically it says I can only be tested when I have a valid space, and
you get a really complex one to test with, the one where everything else
is running in. Having that space, it tends to be difficult not to depend
on that space (and why would you, as it is the space you want).
   For testing, I mostly don't want the space to be one that can be
easily changed behind my back. Basically,the arguments from an old
smalltalker [GOOS]

Stephan

[GOOS] Nat Pryce, Steve Freeman (2009) Growing Object-Oriented Software,
Guided By Tests


Reply | Threaded
Open this post in threaded view
|

Re: [bloc] why redefining new is not enough?

stepharo
In reply to this post by Aliaksei Syrel
Can you create a bug entry? we should log the bloc design improvements to not forget them.

Le 25/2/16 14:08, Aliaksei Syrel a écrit :

An we need NullSpace to be default value.

On Feb 25, 2016 2:06 PM, "Aliaksei Syrel" <[hidden email]> wrote:

Well, it is not *important* for design what method is redefined new or basicNew in order to set space. My question is why do we need at all to set space? It means that element created (not added) while spaceA is running can not be used in or added to spaceB.
The only reason that I know is a possibility to add global event listener to space while initializing an element. This must be fixed by having lazy addition of global event listeners.

On Feb 25, 2016 9:55 AM, "stepharo" <[hidden email]> wrote:
BlElement class>>basicNew
    "Redefined to set the space of the element"

    ^ super basicNew basicSpace: BlUniverse default runningSpace

why redefining new is not enough?

Ok now back to the mooc videos :(



Reply | Threaded
Open this post in threaded view
|

Re: [bloc] why redefining new is not enough?

stepharo
In reply to this post by Aliaksei Syrel
Aliaksei

can you log this action somewhere?
in a bloc bug entry?

Stef

Le 25/2/16 14:06, Aliaksei Syrel a écrit :

Well, it is not *important* for design what method is redefined new or basicNew in order to set space. My question is why do we need at all to set space? It means that element created (not added) while spaceA is running can not be used in or added to spaceB.
The only reason that I know is a possibility to add global event listener to space while initializing an element. This must be fixed by having lazy addition of global event listeners.

On Feb 25, 2016 9:55 AM, "stepharo" <[hidden email]> wrote:
BlElement class>>basicNew
    "Redefined to set the space of the element"

    ^ super basicNew basicSpace: BlUniverse default runningSpace

why redefining new is not enough?

Ok now back to the mooc videos :(