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 :( |
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 :( > > |
> 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 :( >> >> > > |
Hi, 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]>:
|
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 |
In reply to this post by Pharo Smalltalk Developers mailing list
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).
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
|
In reply to this post by Clément Béra
I just sent the same example ;)
|
In reply to this post by EstebanLM
ok
this is how I intended to fix it.
maybe, I don’t know. thanks Alain
|
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 > > |
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. On Feb 25, 2016 9:55 AM, "stepharo" <[hidden email]> wrote:
BlElement class>>basicNew |
An we need NullSpace to be default value. On Feb 25, 2016 2:06 PM, "Aliaksei Syrel" <[hidden email]> wrote:
|
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 |
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 :
|
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 :
|
Free forum by Nabble | Edit this page |