Summary
In this chapter, we described class delegates, property delegates, and how they can be used to remove redundancy in code. We defined a delegate as an object to which calls from other objects or properties are delegated. We learned design patterns that class delegation is strongly connected to: the Delegate pattern and the Decorator pattern.
The delegation pattern was mentioned as an alternative to inheritance, and the Decorator pattern is a way to add functionality to different kinds of classes that implements the same interface.
We've seen how property delegation works, the Kotlin standard library property delegates notNull, lazy, observable, and vetoable, and the use of Map as a delegate. We learned how they work and when they should ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access