Template constructors for reusable object initialization

Marko Martin, Mira Mezini, Sebastian Erdweg
2013 Proceedings of the 12th international conference on Generative programming: concepts & experiences - GPCE '13  
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
more » ... ors 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.
doi:10.1145/2517208.2517212 dblp:conf/gpce/MartinME13 fatcat:lyuacajjijaf3dr7roolw26tt4