hyperoslo / android-playbook

MIT License
6 stars 2 forks source link

Kotlin: lazy initialization #24

Open sindrenm opened 8 years ago

sindrenm commented 8 years ago

Per the current guidelines, we should “always” lazily initialize member variables. However, I'm not sure if this is a good idea. I agree that we should lazily initialize final members that cannot be initialized in a constructor (quite common in Android, due to the framework not being available until a hook method like onCreate has been called), and in those cases the lazy delegate is awesome. But for cases where you can directly initialize members in a constructor (init { ... }) or even directly when declaring it, I prefer those methods.