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.
- 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 Scholar
Digital Library
- K. Arnold, J. Gosling, and D. Holmes. Java(TM) Programming Language, The (4th Edition). Addison-Wesley Professional, 2005. Google Scholar
Digital Library
- G. Bracha and W. Cook. Mixin-based inheritance. In OOPSLA/ECOOP, pages 303--311. ACM, 1990. Google Scholar
Digital Library
- E. Bruneton, R. Lenglet, and T. Coupaye. ASM: A code manipulation tool to implement adaptable systems. In Adaptable and extensible component systems, 2002.Google Scholar
- L. G. DeMichiel and R. P. Gabriel. The Common Lisp Object System: An overview. In ECOOP, pages 151--170. Springer, 1987. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- T. Ekman and G. Hedin. The JastAdd system - modular extensible compiler construction. Sci. Comput. Program., 69 (1--3): 14--26, 2007. Google Scholar
Digital Library
- M. A. Ellis and B. Stroustrup. The annotated C++ reference manual. Addison-Wesley Longman Publishing Co., Inc., 1990. Google Scholar
Digital Library
- M. Flatt, R. B. Findler, and M. Felleisen. Scheme with classes, mixins, and traits. In APLAS, pages 270--289, 2006. Google Scholar
Digital Library
- A. Goldberg and D. Robson. Smalltalk-80: the language and its implementation. Addison-Wesley Longman Publishing Co., Inc., 1983. Google Scholar
Digital Library
- A. Hejlsberg, M. Torgersen, S. Wiltamuth, and P. Golde. C# Programming Language. Addison-Wesley Professional, 4th edition, 2010. Google Scholar
Digital Library
- J. Järvi. Tuples and multiple return values in C++. Technical report, Turku Centre for Computer Science, 1999. Google Scholar
Digital Library
- D. Malayeri and J. Aldrich. CZ: multiple inheritance without diamonds. In OOPSLA, pages 21--40, 2009. Google Scholar
Digital Library
- B. Meyer. Eiffel: A language and environment for software engineering. Journal of Systems and Software, 8 (3): 199--246, 1988. Google Scholar
Digital Library
- G. Mohr, M. Kimpton, M. Stack, and I. Ranitovic. Introduction to Heritrix, an archival quality web crawler. In International Web Archiving Workshop, 2004.Google Scholar
- D. A. Moon. Object-oriented programming with flavors. In OOPLSA, pages 1--8. ACM, 1986. Google Scholar
Digital Library
- M. Odersky, L. Spoon, and B. Venners. Programming in Scala. Artima, 2008.Google Scholar
- Y. Smaragdakis and D. S. Batory. Mixin-based programming in C++. In GCSE, pages 163--177. Springer, 2001. Google Scholar
Digital Library
- B. Stroustrup. The design and evolution of C++. ACM Press/Addison-Wesley Publishing Co., 1994. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- M. VanHilst and D. Notkin. Using role components in implement collaboration-based designs. In OOPSLA, pages 359--369. ACM, 1996. Google Scholar
Digital Library
Index Terms
Template constructors for reusable object initialization
Recommendations
Template constructors for reusable object initialization
GPCE '13: Proceedings of the 12th international conference on Generative programming: concepts & experiencesReuse 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 ...
A type-and-effect system for object initialization
Every newly created object goes through several initialization states: starting from a state where all fields are uninitialized until all of them are assigned. Any operation on the object during its initialization process, which usually happens in the ...
A mechanized semantics for C++ object construction and destruction, with applications to resource management
POPL '12We present a formal operational semantics and its Coq mechanization for the C++ object model, featuring object construction and destruction, shared and repeated multiple inheritance, and virtual function call dispatch. These are key C++ language ...







Comments