Search

Modularizing constructors

By: Viviana Bono, Jaroslaw D. M. Kúsmierek

Abstract

Object-oriented class-based languages provide mechanisms for the initialization of newly created objects. These mechanisms specify how an object is initialized and what information is needed to do so. The initialization protocol is usually implemented as a list of constructors. It is often the case that the initialization protocol concerns some orthogonal properties of objects. Unfortunately, if those properties have more than one option of initialization, the total number of constructors becomes exponential in the number of properties. In this paper, we propose an alternative protocol. In our approach, instead of defining a list of constructors, it is possible to split blocks of definitions into smaller and composable pieces, in order to obtain reduction in the size of the code, better reusability, more expressiveness, and easier maintenance.

Cite as:

Viviana Bono, Jaroslaw D. M. Kúsmierek, “Modularizing constructors”, Journal of Object Technology, Volume 6, no. 9 (October 2007), pp. 297-317, doi:10.5381/jot.2007.6.9.a15.

PDF | HTML | DOI | BiBTeX | Tweet this | Post to CiteULike | Share on LinkedIn