Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Kotlin "by" Delegation

Kotlin "by" Delegation

Delegation is design pattern that allows same code reuse as inheritance. In this talk we go through the details of why we should favor composition over inheritance by using delegation pattern and how the Kotlin programming language implements this concept out of the box.

Rygel Louv

January 19, 2019
Tweet

More Decks by Rygel Louv

Other Decks in Programming

Transcript

  1. Kotlin “by” Delegation G O O G L E D

    E V E L O P E R G R O U P D A K A R R y g e l L o u v
  2. I am here because I know few stuff about programming.

    Hello! I Am Rygel Louv @rygelouv @rygellouv @rygel
  3. “ “In software engineering, the delegation pattern is an object-oriented

    design pattern that allows object composition to achieve the same code reuse as inheritance.” —Wikipedia
  4. Rules Can only delegates Interface Must have a concrete class

    that implements the Interface class ClassName: ParentInterface by ObjectDelegate Syntax: Delegate to instance object of that concrete class
  5. Lazy property delegation By default, the evaluation of lazy properties

    is synchronized: the value is computed only in one thread, and all threads will see the same value.