September 2019
Intermediate to advanced
462 pages
11h 3m
English
In the previous chapter, you saw that Kotlin offers a different and safer way to use inheritance than Java. Likewise, Kotlin has much better support than Java for delegation. Before we dive into the syntax for delegation, we’ll take a small problem and design it using inheritance, to better understand the reasons to use delegation over inheritance. Soon we’ll run into issues where inheritance begins to become a hindrance, and you’ll see how delegation may be a better choice for the problem. We’ll then look at how Kotlin is able to readily support our new design using delegation, without flinching.
Imagine an application that simulates the execution of software projects by corporate teams (don’t worry, ...
Read now
Unlock full access