tag:blogger.com,1999:blog-831919787210015364.post3479697063645934866..comments2022-10-12T02:12:04.604+03:00Comments on D.EV: Remove class inheritance from JavaPetar Dochevhttp://www.blogger.com/profile/12878691100856841782noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-831919787210015364.post-26336913981795291822012-09-02T22:27:51.632+03:002012-09-02T22:27:51.632+03:00I prefer composition over inheritance too.
But I ...I prefer composition over inheritance too.<br /><br />But I would like to comment your second proposal (about the 'via' operator). To be honest, I don't see any real applications of this construct. Maybe anI is instance of a class providing default implementations of methods in the I interface?<br /><br />In languages like Scala there are no such things as interfaces, they are rather replaced by traits. These look in a way like Java interfaces. But you can have there method implementations (and not only declarations). Something similar we are going to have in Java 8 as well: the default method implementations in interfaces. So you will be able to provide default implementations of foo() and moo() in your I interface and then you decide whether you want to override those implementations in class A.Ivan St. Ivanovhttps://www.blogger.com/profile/11941847497137528869noreply@blogger.comtag:blogger.com,1999:blog-831919787210015364.post-37962962391878290982012-08-30T12:28:01.507+03:002012-08-30T12:28:01.507+03:00I agree that composition should be preferred over ...I agree that composition should be preferred over inheritance in most cases. Yet, inheritance offers a much more natural way to express an "is a" relationship between classes than composition (even thought it's possible to use composition as well). This relationship appears relatively often, which is why inheritance is also used relatively often, in a perfectly legal way.<br />Inheritance can also be abused, which could lead to some pretty ugly and hard to understand code. But this is not a valid enough reason to remove a useful feature from a language, from my perspective. <br />Inheritance is present in most JVM-based programming languages, including new and extremely innovative ones. When it comes to programming languages, I tend to value "expressive power" much higher than "simplicity". Long live Scala ;-)Stoyan Rachevhttps://www.blogger.com/profile/11197464846739184058noreply@blogger.com