skip to main content
research-article

Template constructors for reusable object initialization

Authors Info & Claims
Published:27 October 2013Publication History
Skip Abstract Section

Abstract

Reuse of and abstraction over object initialization logic is not properly supported in mainstream object-oriented languages. This may result in significant amount of boilerplate code and proliferation of constructors in subclasses. It also makes it impossible for mixins to extend the initialization interface of classes they are applied to. We propose template constructors, which employ template parameters and pattern matching of them against signatures of superclass constructors to enable a one-to-many binding of super-calls. We demonstrate how template constructors solve the aforementioned problems. We present a formalization of the concept, a Java-based implementation, and use cases which exercise its strengths.

References

  1. I. Aracic, V. Gasiunas, M. Mezini, and K. Ostermann. An overview of CaesarJ. In Transactions on Aspect-Oriented Software Development, LNCS, pages 135--173. Springer, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. K. Arnold, J. Gosling, and D. Holmes. Java(TM) Programming Language, The (4th Edition). Addison-Wesley Professional, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. G. Bracha and W. Cook. Mixin-based inheritance. In OOPSLA/ECOOP, pages 303--311. ACM, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. E. Bruneton, R. Lenglet, and T. Coupaye. ASM: A code manipulation tool to implement adaptable systems. In Adaptable and extensible component systems, 2002.Google ScholarGoogle Scholar
  5. L. G. DeMichiel and R. P. Gabriel. The Common Lisp Object System: An overview. In ECOOP, pages 151--170. Springer, 1987. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. U. Eisenecker, F. Blinn, and K. Czarnecki. A solution to the constructor-problem of mixin-based programming in C++. In GCSE'2000 Workshop on C++ Template Programming, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. T. Ekman and G. Hedin. The JastAdd system - modular extensible compiler construction. Sci. Comput. Program., 69 (1--3): 14--26, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. M. A. Ellis and B. Stroustrup. The annotated C++ reference manual. Addison-Wesley Longman Publishing Co., Inc., 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. M. Flatt, R. B. Findler, and M. Felleisen. Scheme with classes, mixins, and traits. In APLAS, pages 270--289, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. A. Goldberg and D. Robson. Smalltalk-80: the language and its implementation. Addison-Wesley Longman Publishing Co., Inc., 1983. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. A. Hejlsberg, M. Torgersen, S. Wiltamuth, and P. Golde. C# Programming Language. Addison-Wesley Professional, 4th edition, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. J. Järvi. Tuples and multiple return values in C++. Technical report, Turku Centre for Computer Science, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. D. Malayeri and J. Aldrich. CZ: multiple inheritance without diamonds. In OOPSLA, pages 21--40, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. B. Meyer. Eiffel: A language and environment for software engineering. Journal of Systems and Software, 8 (3): 199--246, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. G. Mohr, M. Kimpton, M. Stack, and I. Ranitovic. Introduction to Heritrix, an archival quality web crawler. In International Web Archiving Workshop, 2004.Google ScholarGoogle Scholar
  16. D. A. Moon. Object-oriented programming with flavors. In OOPLSA, pages 1--8. ACM, 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. M. Odersky, L. Spoon, and B. Venners. Programming in Scala. Artima, 2008.Google ScholarGoogle Scholar
  18. Y. Smaragdakis and D. S. Batory. Mixin-based programming in C++. In GCSE, pages 163--177. Springer, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. B. Stroustrup. The design and evolution of C++. ACM Press/Addison-Wesley Publishing Co., 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. E. Tempero, C. Anslow, J. Dietrich, T. Han, J. Li, M. Lumpe, H. Melton, and J. Noble. Qualitas corpus: A curated collection of Java code for empirical studies. In APSEC, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. M. VanHilst and D. Notkin. Using role components in implement collaboration-based designs. In OOPSLA, pages 359--369. ACM, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Template constructors for reusable object initialization

            Recommendations

            Comments

            Login options

            Check if you have access through your login credentials or your institution to get full access on this article.

            Sign in

            Full Access

            • Published in

              cover image ACM SIGPLAN Notices
              ACM SIGPLAN Notices  Volume 49, Issue 3
              GPCE '13
              March 2014
              181 pages
              ISSN:0362-1340
              EISSN:1558-1160
              DOI:10.1145/2637365
              Issue’s Table of Contents
              • cover image ACM Conferences
                GPCE '13: Proceedings of the 12th international conference on Generative programming: concepts & experiences
                October 2013
                198 pages
                ISBN:9781450323734
                DOI:10.1145/2517208

              Copyright © 2013 ACM

              Publisher

              Association for Computing Machinery

              New York, NY, United States

              Publication History

              • Published: 27 October 2013

              Check for updates

              Qualifiers

              • research-article
            • Article Metrics

              • Downloads (Last 12 months)3
              • Downloads (Last 6 weeks)1

              Other Metrics

            PDF Format

            View or Download as a PDF file.

            PDF

            eReader

            View online with eReader.

            eReader
            About Cookies On This Site

            We use cookies to ensure that we give you the best experience on our website.

            Learn more

            Got it!