A TYPE SAFE DESIGN TO ALLOW THE SEPARATION OF DIFFERENT RESPONSIBILITIES INTO PARALLEL HIERARCHIES
Francisco Ortin, Miguel García
2011
Abstract
The Tease Apart Inheritance refactoring is used to avoid tangled inheritance hierarchies that lead to code duplication. This big refactoring creates two parallel hierarchies and uses delegation to invoke one from the other. One of the drawbacks of this approach is that the root class of the new refactored hierarchy should be general enough to provide all its services. This weakness commonly leads to meaningless interfaces that violate the Liskov substitution principle. This paper describes a behavioral design pattern that allows modu-larization of different responsibilities in separate hierarchies that collaborate to achieve a common goal. It allows using the specific interface of each class in the parallel hierarchy, without imposing a meaningless interface to its root class. The proposed design is type safe, meaning that the compile-time type checking ensures that no type error will be produced at runtime, avoiding the use of dynamic type checking and re-flection.
References
- Appel A.W., 2002. Modern Compiler Implementation in Java, 2nd Edition, Cambridge University Press.
- Canning P., Cook W., Hill W., Walter O., and Mitchell J. C., 1989. F-bounded polymorphism for objectoriented programming, in Proceedings of the fourth International Conference on Functional Programming Languages and Computer Architecture, London, United Kingdom, pp. 273-280.
- ECMA 335, 2006. European Computer Manufacturers Association (ECMA), Common Language Infrastructure (CLI), Partition IV: CIL Instruction Set, 4th Edition.
- Ernst E., July 2003. Higher-Order Hierarchies. European Conference on Object-Oriented Programming (ECOOP), pp. 303-329, Darmstadt, Germany.
- Fraser C. W., and Hanson D.R., 1995. A Retargetable C Compiler: Design and Implemen-tation, AddisonWesley Professional.
- Fowler M., Beck K., Brant J., Opdyke W., and Roberts D., 1999. Refactoring: Improving the Design of Existing Code, Addison-Wesley Professional.
- Gamma E., Helm R., Johnson R., and Vlissides J., 1994. Design Patterns: Elements of Reusable ObjectOriented Software, Addison Wesley.
- Hugunin J., 2007. Bringing dynamic languages to .NET with the DLR, in Proceedings of the Symposium on Dynamic Languages, Montreal, Quebec, Canada, pp. 101-101.
- JSR 294 Sun Microsystems, 2007. JSR 294: Improved Modularity Support in the Java Programming Language, http://jcp.org/en/jsr/detail?id=294
- Lindholm T., and Yellin F., 1999. Java Virtual Machine Specification, 2nd Edition, Prentice Hall.
- Liskov B., 1987. Data Abstraction and Hierarchy, in Conference on Object Oriented Programming Systems Languages and Applications (OOPSLA), Orlando, Florida, United States, pp. 17-34.
- Meyer J., Jasmin Instructions, 1996. http://jasmin.sourceforge.net/instructions.html
- Nielsen E.T., Larsen K.A., Markert S., Kjaer K.E., May 31 2005. The Expression Problem in Scala. Technical Report, Aarhus University.
- Odersky M., and Wadler P., 1997. Pizza into Java: Translating theory into practice, in Proceedings of the 24th ACM Symposium on Principles of Programming Languages (POPL), Paris, France, pp. 146-159.
- Ortin F., and Garcia M., 2011. Union and intersection types to support both dynamic and statict yping. Information Processing Letters, 111(6):278-286.
- Ortin F., Redondo J.M., and Perez-Schofield J.B.G, 2009. Efficient virtual machine support of runtime structural reflection”, Science of Computer Programming, Vol. 74(10), pp. 836-860.
- Ortin F., Zapico D., and Cueva J, 2007. Design patterns for teaching type checking in a compiler construction course. Education, IEEE Transactionson, 50(3):273- 283.
- Ortin F., Zapico D., Perez-Schofield J.B.G., Garcia M., August 2010. Including both Static and Dynamic Typing in the same Programming Language. IET Software, Volume 4, Issue 4, pp. 268-282.
- Redondo J., Ortin F. and Cueva J, 2008. Optimizing Reflective Primitives of Dynamic Languages. International Journal of Software Engineering and Knowledge Engineering, 18(6):759-783.
- Torgersen M., 2004. The Expression Problem Revisited. European Conference on Object-Oriented Programming (ECOOP), pp. 123-143.
- Wadler P., 1998. The expression problem, Posted on the Java Genericity mailing list.
- Watt D., and Brown D., 2000. Programming Language Processors in Java: Compilers and Interpreters, Prentice Hall.
Paper Citation
in Harvard Style
Ortin F. and García M. (2011). A TYPE SAFE DESIGN TO ALLOW THE SEPARATION OF DIFFERENT RESPONSIBILITIES INTO PARALLEL HIERARCHIES . In Proceedings of the 6th International Conference on Evaluation of Novel Approaches to Software Engineering - Volume 1: ENASE, ISBN 978-989-8425-57-7, pages 15-25. DOI: 10.5220/0003418000150025
in Bibtex Style
@conference{enase11,
author={Francisco Ortin and Miguel García},
title={A TYPE SAFE DESIGN TO ALLOW THE SEPARATION OF DIFFERENT RESPONSIBILITIES INTO PARALLEL HIERARCHIES},
booktitle={Proceedings of the 6th International Conference on Evaluation of Novel Approaches to Software Engineering - Volume 1: ENASE,},
year={2011},
pages={15-25},
publisher={SciTePress},
organization={INSTICC},
doi={10.5220/0003418000150025},
isbn={978-989-8425-57-7},
}
in EndNote Style
TY - CONF
JO - Proceedings of the 6th International Conference on Evaluation of Novel Approaches to Software Engineering - Volume 1: ENASE,
TI - A TYPE SAFE DESIGN TO ALLOW THE SEPARATION OF DIFFERENT RESPONSIBILITIES INTO PARALLEL HIERARCHIES
SN - 978-989-8425-57-7
AU - Ortin F.
AU - García M.
PY - 2011
SP - 15
EP - 25
DO - 10.5220/0003418000150025