Abstract
When tangled inheritance hierarchies lead to code duplication, the Tease Apart Inheritance "big" refactoring is commonly used to create two parallel hierarchies, using delegation to invoke one from the other. Under these circumstances, the root class of the refactored hierarchy must be general enough to provide all its services to the other hierarchy, leading to meaningless interfaces that violate the Liskov substitution principle. In order to avoid this limitation, we propose a behavioral design pattern that allows the modularization of different responsibilities in separate hierarchies that collaborate to achieve a common goal. With this design, it is possible to use the specific interface of each class in the parallel hierarchy, without needing to define all the methods provided by every class in the hierarchy, and hence not violating the Liskov substitution principle. The proposed design is type safe and avoids the use of dynamic type checking and reflection; at compile time, the type system ensures that no type error will be produced dynamically.
Keywords
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
Hanson, D.R., Fraser, C.W.: A Retargetable C Compiler: Design and Implementation. Addison-Wesley Professional (1995)
Appel, A.W.: Modern Compiler Implementation in Java, 2nd edn. Cambridge University Press (2002)
Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design Patterns: Elements of Re-usable Object-Oriented Software. Addison Wesley (1994)
Watt, D., Brown, D.: Programming Language Processors in Java: Compilers and Interpreters. Prentice Hall (2000)
Lindholm, T., Yellin, F.: Java Virtual Machine Specification, 2nd edn. Prentice Hall (1999)
ECMA 335, European Computer Manufacturers Association (ECMA). Common Language Infrastructure (CLI), Partition IV: CIL Instruction Set, 4th edn. (2006)
Fowler, M., Beck, K., Brant, J., Opdyke, W., Roberts, D.: Refactoring: Improving the Design of Existing Code. Addison-Wesley Professional (1999)
Liskov, B.: Data Abstraction and Hierarchy. In: Conference on Object Oriented Programming Systems Languages and Applications (OOPSLA), Orlando, Florida, United States, pp. 17–34 (1987)
Ortin, F., Redondo, J.M., Perez-Schofield, J.B.G.: Efficient virtual machine support of runtime structural reflection. Science of Computer Programming 74(10), 836–860 (2009)
Canning, P., Cook, W., Hill, W., Walter, O., Mitchell, J.C.: F-bounded polymorphism for object-oriented programming. In: Proceedings of the Fourth International Conference on Functional Programming Languages and Computer Architecture, London, United Kingdom, pp. 273–280 (1989)
Odersky, M., Wadler, P.: 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 (1997)
JSR 294 Sun Microsystems, JSR 294: Improved Modularity Support in the Java Programming Language (2007), http://jcp.org/en/jsr/detail?id=294
Meyer, J.: Jasmin Instructions (1996), http://jasmin.sourceforge.net/instructions.html
Ortin, F., Zapico, D., Perez-Schofield, J.B.G., Garcia, M.: Including both Static and Dynamic Typing in the same Programming Language. IET Software 4(4), 268–282 (2010)
Hugunin, J.: Bringing dynamic languages to .NET with the DLR. In: Proceedings of the Symposium on Dynamic Languages, Montreal, Quebec, Canada, p. 101 (2007)
Wadler, P.: The expression problem. Posted on the Java Genericity Mailing List (1998)
Torgersen, M.: The Expression Problem Revisited. In: Vetta, A. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 123–146. Springer, Heidelberg (2004)
Nielsen, E.T., Larsen, K.A., Markert, S., Kjaer, K.E.: The Expression Problem in Scala. Technical Report, Aarhus University (May 31, 2005)
Ernst, E.: Higher-Order Hierarchies. In: Cardelli, L. (ed.) ECOOP 2003. LNCS, vol. 2743, pp. 303–329. Springer, Heidelberg (2003)
Ortin, F., Garcia, M.: Union and intersection types to support both dynamic and static typing. Information Processing Letters 111(6), 278–286 (2011)
Redondo, J., Ortin, F., Cueva, J.: Optimizing Reflective Primitives of Dynamic Languages. International Journal of Software Engineering and Knowledge Engineering 18(6), 759–783 (2008)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2013 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Ortin, F., Garcia, M. (2013). Modularizing Different Responsibilities into Separate Parallel Hierarchies. In: Maciaszek, L.A., Zhang, K. (eds) Evaluation of Novel Approaches to Software Engineering. ENASE 2011. Communications in Computer and Information Science, vol 275. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-32341-6_2
Download citation
DOI: https://doi.org/10.1007/978-3-642-32341-6_2
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-32340-9
Online ISBN: 978-3-642-32341-6
eBook Packages: Computer ScienceComputer Science (R0)