vendredi 3 août 2018

Classes with final annotation by default on Kotlin: what a really motivation?

Documentation tell us the follow about open annotation

The open annotation on a class is the opposite of Java's final: it allows others to inherit from this class. By default, all classes in Kotlin are final, which corresponds to Effective Java, 3rd Edition, Item 19: Design and document for inheritance or else prohibit it.

My classes

class Foo //I can't inherit it
open class Bar //I can inherit it

Then, what the really motivation to all classes are final by default? Any gain on performance? Or just it is a design pattern? Why prohibit open by default?

Aucun commentaire:

Enregistrer un commentaire