Skip to main content

Challenges in the Design of the Package Template Mechanism

  • Chapter

Part of the book series: Lecture Notes in Computer Science ((TAOSD,volume 7271))

Abstract

Package Templates are a mechanism for writing modules meant for reuse, where each module (template) consists of a collection of classes. A package template must be instantiated in a program at compile time to form a set of ordinary classes, and during instantiation, the classes may be adapted by means of renaming, adding attributes (fields and methods), and supplying type parameters. An approach like this naturally gives rise to two distinct dimensions along which classes can be extended. One is the ordinary subclass dimension, while the other is comprised of the ability to adapt classes during instantiations. The latter dimension also allows for a form of static multiple inheritance, in that classes from two or more instantiations may be merged to form a new class. This will be handled entirely at compile time, and the new class will have all the attributes from the merged classes and also the attributes added in the instantiating template. This paper discusses how these two dimensions play together in the different mechanisms that make up the Package Templates approach, and the design considerations involved. The paper also argues that the compromise made in Package Templates between simplicity of the type system on the one hand and expressiveness on the other is, for most purposes, better than similar approaches based on virtual classes.

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. Dahl, O.J., Myhrhaug, B., Nygaard, K.: Simula 67 common base language. Technical Report Publication No. S-22 (Revised edition of publication S-2), Norwegian Computing Center (1970)

    Google Scholar 

  2. Stroustrup, B.: Multiple inheritance for C++. Computing Systems 2(4), 367–395 (1989)

    Google Scholar 

  3. Bracha, G.: Generics in the Java programming language. Technical report, Sun Microsystems, Santa Clara, CA (2004), http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf

  4. Madsen, O.L., Møller-Pedersen, B.: Virtual classes: a powerful mechanism in object-oriented programming. In: OOPSLA 1989: Conference Proceedings on Object-Oriented Programming Systems, Languages and Applications, pp. 397–406. ACM, New York (1989)

    Chapter  Google Scholar 

  5. Madsen, O.L., Møller-Pedersen, B., Nygaard, K.: Object-oriented programming in the BETA programming language. ACM Press/Addison-Wesley Publishing Co., New York, NY, USA (1993)

    Google Scholar 

  6. Kiczales, G., Lamping, J., Menhdhekar, A., Maeda, C., Lopes, C., Loingtier, J.-M., Irwin, J.: Aspect-Oriented Programming. In: Aksit, M., Matsuoka, S. (eds.) ECOOP 1997. LNCS, vol. 1241, pp. 220–242. Springer, Heidelberg (1997)

    Chapter  Google Scholar 

  7. Schärli, N., Ducasse, S., Nierstrasz, O., Black, A.: Traits: Composable Units of Behavior. In: Cardelli, L. (ed.) ECOOP 2003. LNCS, vol. 2743, pp. 327–339. Springer, Heidelberg (2003)

    Google Scholar 

  8. Bracha, G., Cook, W.: Mixin-based inheritance. In: Meyrowitz, N. (ed.) OOPSLA/ECOOP, Ottawa, Canada, pp. 303–311. ACM Press (1990)

    Google Scholar 

  9. Krogdahl, S., Møller-Pedersen, B., Sørensen, F.: Exploring the use of package templates for flexible re-use of collections of related classes. Journal of Object Technology 8(7), 59–85 (2009)

    Article  Google Scholar 

  10. Sørensen, F., Axelsen, E.W., Krogdahl, S.: Reuse and combination with package templates. In: Proceedings of the 4th Workshop on MechAnisms for SPEcialization, Generalization and inHerItance, MASPEGHI 2010, pp. 3:1–3:5. ACM, New York (2010)

    Chapter  Google Scholar 

  11. Axelsen, E.W., Krogdahl, S.: Groovy package templates: supporting reuse and runtime adaption of class hierarchies. In: DLS 2009: Proceedings of the 5th Symposium on Dynamic Languages, pp. 15–26. ACM, New York (2009)

    Chapter  Google Scholar 

  12. Axelsen, E.W., Krogdahl, S., Møller-Pedersen, B.: Controlling dynamic module composition through an extensible meta-level API. In: DLS 2010: Proceedings of the 6th Symposium on Dynamic Languages. ACM, New York (2010)

    Google Scholar 

  13. Ernst, E.: Gbeta - a language with virtual attributes, block structure, and propagating, dynamic inheritance (1999)

    Google Scholar 

  14. Aracic, I., Gasiunas, V., Awasthi, P., Ostermann, K.: An Overview of CaesarJ. In: Rashid, A., Aksit, M. (eds.) Transactions on AOSD I. LNCS, vol. 3880, pp. 135–173. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  15. Nystrom, N., Chong, S., Myers, A.C.: Scalable extensibility via nested inheritance. In: OOPSLA 2004: Proceedings of the 19th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, pp. 99–115. ACM, New York (2004)

    Chapter  Google Scholar 

  16. Nystrom, N., Qi, X., Myers, A.C.: J&: nested intersection for scalable software composition. In: OOPSLA 2006: Proceedings of the 21st Annual ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and applications, pp. 21–36. ACM, New York (2006)

    Chapter  Google Scholar 

  17. Bracha, G., von der Ahé, P., Bykov, V., Kashai, Y., Maddox, W., Miranda, E.: Modules as Objects in Newspeak. In: D’Hondt, T. (ed.) ECOOP 2010. LNCS, vol. 6183, pp. 405–428. Springer, Heidelberg (2010)

    Chapter  Google Scholar 

  18. Compagnoni, A.B., Pierce, B.C.: Higher-order intersection types and multiple inheritance. Mathematical Structures in Computer Science 6, 469–501 (1996)

    MathSciNet  MATH  Google Scholar 

  19. Ernst, E., Ostermann, K., Cook, W.R.: A virtual class calculus. In: Conference record of the 33rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2006, pp. 270–282. ACM, New York (2006)

    Chapter  Google Scholar 

  20. Torgersen, M.: The Expression Problem Revisited Four New Solutions Using Generics. In: Odersky, M. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 123–146. Springer, Heidelberg (2004)

    Chapter  Google Scholar 

  21. Ernst, E.: The expression problem, scandinavian style. In: Lahire, P., Arévalo, G., Astudillo, H., Black, A.P., Ernst, E., Huchard, M., Sakkinen, M., Valtchev, P. (eds.) MASPEGHI 2004 (2004)

    Google Scholar 

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

    Google Scholar 

  23. Ekman, T., Hedin, G.: The JastAdd extensible Java compiler. SIGPLAN Not. 42, 1–18 (2007)

    Article  Google Scholar 

  24. Ekman, T., Hedin, G.: The JastAdd system — modular extensible compiler construction. Sci. Comput. Program. 69, 14–26 (2007)

    Article  MathSciNet  MATH  Google Scholar 

  25. Bergel, A., Ducasse, S., Nierstrasz, O., Wuyts, R.: Stateful traits and their formalization. Computer Languages, Systems & Structures 34, 83–108 (2008)

    Article  Google Scholar 

  26. Nierstrasz, O., Ducasse, S., Reichhart, S., Schärli, N.: Adding Traits to (Statically Typed) Languages. Technical Report IAM-05-006, Institut für Informatik, Universität Bern, Switzerland (2005)

    Google Scholar 

  27. Ernst, E.: Family polymorphism. In: Lindskov Knudsen, J. (ed.) ECOOP 2001. LNCS, vol. 2072, pp. 303–326. Springer, Heidelberg (2001)

    Chapter  Google Scholar 

  28. Saito, C., Igarashi, A., Viroli, M.: Lightweight family polymorphism. J. Funct. Program. 18, 285–331 (2008)

    Article  MathSciNet  MATH  Google Scholar 

  29. Igarashi, A., Viroli, M.: Variant path types for scalable extensibility. In: Proceedings of the 22nd Annual ACM SIGPLAN Conference on Object-Oriented Programming Systems and Applications, OOPSLA 2007, pp. 113–132. ACM, New York (2007)

    Chapter  Google Scholar 

  30. Bergel, A., Ducasse, S., Nierstrasz, O.: Classbox/J: controlling the scope of change in Java. In: Proceedings of the 20th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2005, pp. 177–189. ACM, New York (2005)

    Chapter  Google Scholar 

  31. Clifton, C., Millstein, T., Leavens, G.T., Chambers, C.: MultiJava: Design rationale, compiler implementation, and applications. ACM Trans. Program. Lang. Syst. 28, 517–575 (2006)

    Article  Google Scholar 

  32. Warth, A., Stanojević, M., Millstein, T.: Statically scoped object adaptation with expanders. In: Proceedings of the 21st Annual ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications, OOPSLA 2006, pp. 37–56. ACM, New York (2006)

    Chapter  Google Scholar 

  33. Ichisugi, Y., Tanaka, A.: Difference-Based Modules: A Class-Independent Module Mechanism. In: Magnusson, B. (ed.) ECOOP 2002. LNCS, vol. 2374, pp. 62–88. Springer, Heidelberg (2002)

    Chapter  Google Scholar 

  34. Corradi, A., Servetto, M., Zucca, E.: DeepFJig - modular composition of nested classes. In: 2010 International Workshop on Foundations of Object-Oriented Languages, FOOL 2010 (2010)

    Google Scholar 

  35. Ledgard, H.: Reference Manual for the ADA Programming Language. Springer-Verlag New York, Inc., Secaucus (1983)

    Google Scholar 

  36. Barnes, J.: Programming in Ada95. Addison Wesley Longman Publishing Co., Inc., Redwood City (1995)

    Google Scholar 

  37. Colyer, A.: AspectJ. In: Aspect-Oriented Software Development, pp. 123–143. Addison-Wesley (2005)

    Google Scholar 

  38. Filman, R.E., Friedman, D.P.: Aspect-oriented programming is quantification and obliviousness. In: Filman, R.E., Elrad, T., Clarke, S., Akşit, M. (eds.) AOSD, pp. 21–31. Addison-Wesley (2005)

    Google Scholar 

  39. Störzer, M., Koppen, C.: Pcdiff: Attacking the fragile pointcut problem, abstract. In: EIWAS, Berlin, Germany (2004)

    Google Scholar 

  40. Axelsen, E.W., Sørensen, F., Krogdahl, S.: A reusable observer pattern implementation using package templates. In: ACP4IS 2009: Proceedings of the 8th Workshop on Aspects, Components, and Patterns for Infrastructure Software, pp. 37–42. ACM, New York (2009)

    Chapter  Google Scholar 

  41. Hannemann, J., Kiczales, G.: Design pattern implementation in Java and AspectJ. SIGPLAN Not. 37, 161–173 (2002)

    Article  Google Scholar 

  42. Mezini, M., Ostermann, K.: Conquering aspects with Caesar. In: AOSD 2003, pp. 90–99. ACM, New York (2003)

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2012 Springer-Verlag Berlin Heidelberg

About this chapter

Cite this chapter

Axelsen, E.W., Sørensen, F., Krogdahl, S., Møller-Pedersen, B. (2012). Challenges in the Design of the Package Template Mechanism. In: Leavens, G.T., Chiba, S., Haupt, M., Ostermann, K., Wohlstadter, E. (eds) Transactions on Aspect-Oriented Software Development IX. Lecture Notes in Computer Science, vol 7271. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-35551-6_7

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-35551-6_7

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-35550-9

  • Online ISBN: 978-3-642-35551-6

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics