Open wnagrodzki opened 6 years ago
The initialized property state should be independent from the state of the instance. The initialized property state should be independent from the time of it's initalization.
Consider a simpler phrasing for the above (I think that independence from the time of initialization is in fact independence from the state of the instance, which changes over time):
Property initialization outcome should be independent from the state of the owning instance at the time of the initialization
Then, what is the reasoning behind the rule about initialization not relying on other lazy properties?
What about a situation where initialising a property is costly but is not noticeable by the user? How should we measure this?
@Moskacz If it is not noticeable by the user we do not optimise it
It should be used only to defer property costly initialization. Before using it check if the following rules are met:
self
ininit()
method before all properties are initialized (in that case use implicityly unwrapped optional).To avoid cluttering the interface with lazy property initialization closure, extract it's content to a private method.