skip to main content
research-article

Groovy package templates: supporting reuse and runtime adaption of class hierarchies

Published: 26 October 2009 Publication History

Abstract

We show how package templates, a modularization mechanism originally developed for statically typed languages like Java and C#, can be applied to and implemented in a dynamic language like Groovy, by using the language's capabilities for meta-programming. We then consider a set of examples and discuss dynamic PT from the viewpoints of code modularization and reuse, and dynamic adaption of classes at runtime.

References

[1]
I. Aracic, V. Gasiunas, M. Mezini, and K. Ostermann. An overview of CaesarJ. In Trans. AOSD I, volume 3880 of LNCS, pages 135--173. Springer Berlin / Heidelberg, 2006.
[2]
E. W. Axelsen, F. Sørensen, and S. Krogdahl. A reusable observer pattern implementation using package templates. In ACP4IS '09: Proceedings of the 8th workshop on Aspects, components, and patterns for infrastructure software, pages 37--42, New York, NY, USA, 2009. ACM.
[3]
A. Bergel, S. Ducasse, O. Nierstrasz, and R. Wuyts. Stateful traits and their formalization. Computer Languages, Systems&Structures, 34(2-3):83--108, 2008.
[4]
G. Bracha and W. Cook. Mixin-based inheritance. In N. Meyrowitz, editor, Proc. Conf. O-O. Prog.: Syst., Lang., and Appl. / Proc. ECOOP, pages 303--311, Ottawa, Canada, 1990. ACM Press.
[5]
C. Clifton, G. T. Leavens, C. Chambers, and T. Millstein. Multijava: Modular open classes and symmetric multiple dispatch for Java. In OOPSLA 2000 Conference on Object-Oriented Programming, Systems, Languages, and Applications, Minneapolis, Minnesota, volume 35(10), pages 130--145, 2000.
[6]
A. Colyer. AspectJ. In Aspect-Oriented Software Development, pages 123--143. Addison-Wesley, 2005.
[7]
P. Costanza and R. Hirschfeld. Language constructs for context-oriented programming: an overview of contextl. In DLS '05: Proceedings of the 2005 symposium on Dynamic languages, pages 1--10, New York, NY, USA, 2005. ACM.
[8]
Ecma International. Standard ECMA-334 C# Language Specification, 4th edition, 2006.
[9]
Éric Tanter. Expressive scoping of dynamically-deployed aspects. In AOSD '08: Proceedings of the 7th international conference on Aspect-oriented software development, pages 168--179, New York, 2008. ACM.
[10]
E. Ernst. gbeta - a language with virtual attributes, block structure, and propagating, dynamic inheritance, 1999.
[11]
Extension methods (C# Programming Guide). URL: http://msdn.microsoft.com/en-us/library/bb383977.aspx.
[12]
E. Gamma, R. Helm, R. Johnson, and J. Vlissides. Design Patterns - Elements of Reusable Object-Oriented Software. Addison-Wesley, 1994.
[13]
A. Goldberg and D. Robson. Smalltalk 80 : The Language. Addison-Wesley Series in Computer Science. Addison-Wesley Professional, January 1989.
[14]
J. Gosling, B. Joy, G. Steele, and G. Bracha. Java Language Specification, Second Edition: The Java Series. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, 2000.
[15]
The Grails homepage. URL: http://grails.org.
[16]
The Groovy homepage. URL: http://groovy.codehaus.org.
[17]
Groovy: Runtime vs compile time, static vs dynamic. URL: http://groovy.codehaus.org/Runtime+vs+Compile+time,+Static+vs+Dynamic.
[18]
J. Hannemann and G. Kiczales. Design pattern implementation in Java and AspectJ. SIGPLAN Not., 37(11):161--173, 2002.
[19]
W. Harrison and H. Ossher. Subject-oriented programming: a critique of pure objects. In OOPSLA '93: Proceedings of the eighth annual conference on Object-oriented programming systems, languages, and applications, pages 411--428, New York, NY, USA, 1993. ACM.
[20]
G. Kiczales, J. des Rivières, and D. G. Bobrow. The art of the metaobject protocol. MIT Press, Cambridge, MA, USA, 1991.
[21]
G. Kiczales, J. Lamping, A. Menhdhekar, C. Maeda, C. Lopes, J.-M. Loingtier, and J. Irwin. Aspect-oriented programming. In M. Akşit and S. Matsuoka, editors, Proceedings European Conference on Object-Oriented Programming, volume 1241, pages 220--242. Springer-Verlag, Berlin, Heidelberg, and New York, 1997.
[22]
S. Krogdahl, B. Møller-Pedersen, and F. Sørensen. Exploring the use of package templates for flexible re-use of collections of related classes. To appear in the Journal of Object Technology (available now from http://home.ifi.uio.no/steinkr/papers/), 2009.
[23]
T. Lindholm and F. Yellin. The Java™ Virtual Machine Specification (2nd Edition). Prentice Hall PTR, April 1999.
[24]
O. L. Madsen and B. Møller-Pedersen. Virtual classes: a powerful mechanism in object-oriented programming. In OOPSLA '89: Conference proceedings on Object-oriented programming systems, languages and applications, pages 397--406, New York, NY, USA, 1989. ACM.
[25]
O. L. Madsen, B. Møller-Pedersen, and K. Nygaard. Object-Oriented Programming in the BETA Programming Language. Addison-Wesley, 1993.
[26]
M. Mezini and K. Ostermann. Conquering aspects with Caesar. In AOSD '03, pages 90--99, New York, 2003. ACM.
[27]
O. Nierstrasz, S. Ducasse, S. Reichhart, and N. Schärli. Adding Traits to (Statically Typed) Languages. Technical Report IAM-05-006, Institut für Informatik, Universität Bern, Switzerland, December 2005.
[28]
N. Nystrom, X. Qi, and A. C. Myers. J.: nested intersection for scalable software composition. In OOPSLA '06, pages 21--36, New York, 2006. ACM.
[29]
The Python homepage. URL: http://python.org.
[30]
The Ruby homepage. URL: http://ruby-lang.org.
[31]
The Ruby on Rails homepage. URL: http://rubyonrails.org.
[32]
N. Schärli, S. Ducasse, O. Nierstrasz, and A. Black. Traits: Composable units of behavior. In ECOOP 2003, volume 2743 of LNCS, pages 327--339. Springer Berlin / Heidelberg, 2003.
[33]
F. Sørensen and S. Krogdahl. Generic packages with expandable classes compared with similar approaches. In NIK 2007. Tapir akademisk forlag, 2007.

Cited By

View all

Index Terms

  1. Groovy package templates: supporting reuse and runtime adaption of class hierarchies

      Recommendations

      Comments

      Information & Contributors

      Information

      Published In

      cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 44, Issue 12
      DLS '09
      December 2009
      107 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/1837513
      Issue’s Table of Contents
      • cover image ACM Conferences
        DLS '09: Proceedings of the 5th symposium on Dynamic languages
        October 2009
        118 pages
        ISBN:9781605587691
        DOI:10.1145/1640134
        • Program Chair:
        • James Noble
      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      Published: 26 October 2009
      Published in SIGPLAN Volume 44, Issue 12

      Check for updates

      Author Tags

      1. dynamic languages
      2. modularization
      3. oop
      4. templates

      Qualifiers

      • Research-article

      Contributors

      Other Metrics

      Bibliometrics & Citations

      Bibliometrics

      Article Metrics

      • Downloads (Last 12 months)2
      • Downloads (Last 6 weeks)0
      Reflects downloads up to 01 Jan 2025

      Other Metrics

      Citations

      Cited By

      View all

      View Options

      Login options

      View options

      PDF

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader

      Media

      Figures

      Other

      Tables

      Share

      Share

      Share this Publication link

      Share on social media