oday
12/26/2017, 5:14 PMAndreas Sinz
12/26/2017, 8:37 PMAndreas Sinz
12/26/2017, 8:39 PMDuck
you have two lateinit var
. I'd just put them into the constructor to avoid the lateinit
stuff abstract class Duck(protected var quackBehavior: Quack, ...)
Andreas Sinz
12/26/2017, 8:42 PMStrategy Pattern
could be implemented with delegation https://kotlinlang.org/docs/reference/delegation.html, but kotlin doesn't support "replacing" the delegated object at runtime right now https://youtrack.jetbrains.com/issue/KT-5870oday
12/27/2017, 12:31 PModay
12/27/2017, 12:33 PModay
12/27/2017, 12:33 PMAndreas Sinz
12/27/2017, 12:49 PMprotected
the behavior is accessible from subclasses and they can change the behavior at runtime with quackBehavior = ...
Andreas Sinz
12/27/2017, 12:50 PMprivate
is fine toooday
12/27/2017, 12:50 PModay
12/27/2017, 12:51 PModay
12/27/2017, 12:51 PM