I think the best way to reuse code in Java is the simplest. Which is to say: subclassing.
Unfortunately, the current fashion is that more classes = worse*, which leads to the library style of subclassing, with the attendant problems that people have mentioned (e.g. who maintains it) as well as other problems such as trying to be all things to all people. That leads to overly complex code, because your base classes (i.e. the library) have to accommodate every way in which users of the library might want to use the library in the future. Good luck with that one. Typically when someone wants to re-use code, they have some existing code that already does 90% of what they want, and they then have to try to figure a way to shoe-horn the remaining behaviour out of or into the base class (which of course will mess up everyone else that relies on those classes...). Instead, they should simply subclass the class with 90% of the behaviour they want, and then either add on, or override the methods where they want the behaviour to be slightly different. *We wouldn't even be having the closure debate for instance if people would just man up and create a new class, or, in the case of the closure 'killer app' - which is UI - instead of creating anonymous inner classes they should be subclassing Action. I suspect the cause of the problem is that the popular IDEs (e.g. Eclipse) are bad at handling lots of classes**. If the IDEs sucked less, there would be less pressure to avoid creating more classes. **Which is to say that navigating between class files when you have lots of them open already is a mess, not that it cannot open a whole bunch all at once (e.g. it is a UI issue not a performance issue). --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/javaposse?hl=en -~----------~----~----~----~------~----~------~--~---
