Hacker News new | past | comments | ask | show | jobs | submit login

Example: How in Java do you add a method to the String class so that all instances of String gain the method without extending String and introducing a new subtype ?

It cannot be done. As an example see Categories in Objective-C.

Java's support for composition has improved somewhat with default methods on interfaces in Java 8 but it's still poor compared to the above languages. This leads to the "abundance of classes" anti-pattern you see with Java projects as you are forced to extend to introduce new functionality.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: