Personally I prever to avoid long lazy initializations, so I have it nice and 
tidy in a single method.

        ^ property ifNil: [ property := self bar collect: #food ]

If I want to initialize the value in a separate method (typically for testing 
or reuse), then I prefer to avoid state mutation there and instead I return the 

        ^ property ifNil: [ property := self createNewProperty ]

        "I won't touch property instance variable here, just create a new value 
and return it"
        ^ self bar collect: [ :e | e drink ]

> an initializationMethod returning the value instead of the receiver is a code 
> smell to me.

For this reason I tend to name such methods createNewX, initializeX says to me 
"only mutate state and return self"


Reply via email to