Have gone through the official docs and some tutor...
# announcements
n
Have gone through the official docs and some tutorials online but still quite unsure where and when to use Interface Delegation. When do you use Interface Delegation in your projects? 🤔 Examples and instances would be greatly appreciated. 🙏🏾
n
i use it when i want to compose classes of multiple objects ie common and specifics
Copy code
data class ComposedComponent(
   val common: Common,
   val specific: SpecificComponent
): ICommon by common, ISpecific by specific
it saves typing and making copypaste errors sadly it does not flatten it magically inside serialization
r
u
Use inheritance when you will reference the interface (List, MutableList etc). Else use composition