4 ms·
Can you explain how exactly Java and C++ have poor support for composition? Classes can have member variables in both languages. What else is there?
by anewhnaccount 11y ago
Can you explain how exactly Java and C++ have poor support for composition? Classes can have member variables in both languages. What else is there?
- spiralpolitik 11y agoExample: 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.
- marvel_boy 11y agoObjective-C is years along of Java extending existing classes.
- deleted 11y ago[deleted]