Often I find myself in a situation where I have a superclass that has many optional parameters, and the same parameters should also be optional parameters in their subclasses.
For example, a superclass:
abstract class Plugin(val name: String, val version: String = "1.0", val author: String = "", val description: String = "")
Extending this class is pain. Here is an example of a subclass:
abstract class CyclePlugin(name: String, version: String = "1.0", author: String = "", description: String = "", val duration: Int, val durationUnit: TimeUnit = MILLISECONDS) : Plugin(name, version, author, description)
Note: I will answer this question with my decision. I am looking for a better solution.
constructor duplicates kotlin code-duplication
Jire
source share