+1

Norbert

Am 30.05.2018 um 05:20 schrieb Ben Coman <btc@openinworld.com>:

While protoyping in a "live" system like Pharo, you often may add a new instance variable to existing object, 
the value of which is "nil" and may break the associated behaviour you next add.  
To deal with that you either have to sprinkle ifNils: around your code,
or alternatively do it in one location with lazy initialization.

So in general, lazy initialization is good for prototyping.
Once you're past prototyping there might be some advantage to refactoring away from lazy initialization.

cheers -ben


 

On 29 May 2018 at 23:49, sergio ruiz <sergio.rrd@gmail.com> wrote:
If a model has a list of things.. such as a user that can/may have lots of pets, are there any real benefits to initializing the list of pets lazily?

like:

self pets := OrderedCollection new.

vs.

pets
 pets ifNil: [self pets: OrderedCollection new]
 ^ pets

thanks!

----
peace,
sergio
photographer, journalist, visionary