by princeofdevils · 3y ago · 0 comments
open class Importer {
fun import() {
// do common logic...
val parsed = parse() // call specialized behaviour
}
open fun parse() { ... }
}
Vs. class Importer(private val parser: Parser) {
fun import() {
// do common logic...
val parsed = parser.Parse() // call specialized behaviour
}
}
In my experience, using inheritance can quickly make things worse.
(Go seems to agree, there is no inheritance in Go, only composition.)No comments yet.