next up previous
Next: Acknowledgments Up: Common Programming Idioms and Previous: 3. Patterns in Java

4. Conclusions

In this paper we reviewed Java idioms used by programmers to approximate generics and multiple inheritance of classes using only single inheritance of classes and multiple inheritance of interfaces, in order to accrue reusability benefits. Multiple inheritance was simulated by the joint use of forwarding as a means to achieve code reuse, interfaces as a means to achieve polymorphism, and back-references as a means to approximate overriding. We also discussed an alternative proposal to simulating delegation in Java, as incorporated in Lava, which extends Java with constructs for type-safe automatic forwarding. We then studied patterns used by the designers of Java / Java APIs, and rationalized inclusion of certain classes in terms of the design patterns they support. This additional documentation, in conjuction with the description of the corresponding design pattern, enables a software engineer to understand the pros and the cons of the API design decisions, and explore possible alternatives. This analysis also shows that Java is a nice case study for various design patterns.



 

T. K. Prasad