Skip to main content

Modularizing Different Responsibilities into Separate Parallel Hierarchies

  • Conference paper

Part of the book series: Communications in Computer and Information Science ((CCIS,volume 275))

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.

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Hanson, D.R., Fraser, C.W.: A Retargetable C Compiler: Design and Implementation. Addison-Wesley Professional (1995)

    Google Scholar 

  2. Appel, A.W.: Modern Compiler Implementation in Java, 2nd edn. Cambridge University Press (2002)

    Google Scholar 

  3. Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design Patterns: Elements of Re-usable Object-Oriented Software. Addison Wesley (1994)

    Google Scholar 

  4. Watt, D., Brown, D.: Programming Language Processors in Java: Compilers and Interpreters. Prentice Hall (2000)

    Google Scholar 

  5. Lindholm, T., Yellin, F.: Java Virtual Machine Specification, 2nd edn. Prentice Hall (1999)

    Google Scholar 

  6. ECMA 335, European Computer Manufacturers Association (ECMA). Common Language Infrastructure (CLI), Partition IV: CIL Instruction Set, 4th edn. (2006)

    Google Scholar 

  7. Fowler, M., Beck, K., Brant, J., Opdyke, W., Roberts, D.: Refactoring: Improving the Design of Existing Code. Addison-Wesley Professional (1999)

    Google Scholar 

  8. 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)

    Google Scholar 

  9. 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)

    Article  MathSciNet  MATH  Google Scholar 

  10. 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)

    Google Scholar 

  11. 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)

    Google Scholar 

  12. JSR 294 Sun Microsystems, JSR 294: Improved Modularity Support in the Java Programming Language (2007), http://jcp.org/en/jsr/detail?id=294

  13. Meyer, J.: Jasmin Instructions (1996), http://jasmin.sourceforge.net/instructions.html

  14. 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)

    Article  Google Scholar 

  15. Hugunin, J.: Bringing dynamic languages to .NET with the DLR. In: Proceedings of the Symposium on Dynamic Languages, Montreal, Quebec, Canada, p. 101 (2007)

    Google Scholar 

  16. Wadler, P.: The expression problem. Posted on the Java Genericity Mailing List (1998)

    Google Scholar 

  17. Torgersen, M.: The Expression Problem Revisited. In: Vetta, A. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 123–146. Springer, Heidelberg (2004)

    Chapter  Google Scholar 

  18. Nielsen, E.T., Larsen, K.A., Markert, S., Kjaer, K.E.: The Expression Problem in Scala. Technical Report, Aarhus University (May 31, 2005)

    Google Scholar 

  19. Ernst, E.: Higher-Order Hierarchies. In: Cardelli, L. (ed.) ECOOP 2003. LNCS, vol. 2743, pp. 303–329. Springer, Heidelberg (2003)

    Chapter  Google Scholar 

  20. Ortin, F., Garcia, M.: Union and intersection types to support both dynamic and static typing. Information Processing Letters 111(6), 278–286 (2011)

    Article  MathSciNet  Google Scholar 

  21. 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)

    Article  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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)

Publish with us

Policies and ethics