Does Kotlin yet have a way to require that impleme...
# android
b
Does Kotlin yet have a way to require that implementors of an interface method call super?
c
interfaces don’t have any idea of inheritance so super wouldn’t mean anything in Kotlin or Java
b
I disagree, interfaces can inherit from one another. I’m actively doing so in a project of mine
I’m using interface inheritance to enforce composition at the class level
And because my classes are parcelable, I allow the writeToParcel method in each interface to call its super to add its own members to the parcel
That’s one use case
c
Interfaces can extend one another, but not inherit. There is nothing to inherit from an interface. Inheritance is an OOP concept, and interfaces are not Objects.
So there isn’t really anything to disagree with.
But to help address your problem, I try to lean towards the Decorator pattern https://en.wikipedia.org/wiki/Decorator_pattern
Rather than forcing a child class method to ask it’s parent method to do work, you pass in a “CommonFoo” class instance to a “SpecificFoo” classes constructor, and allow the “SpecificFoo” class to add additional info to that method
b
Thanks! I will take a deeper look into that