Code modularity is important for code reuse. Language designers mainly focused on method code modularity. On the contrary, initialization code modularity has usually been neglected. The initialization code of many class-based object-oriented languages becomes cumbersome in different situations: for example, when some fields have multiple initialization options (e.g., a rectangle can be positioned by providing Cartesian or polar coordinates), have optional initialization (e.g., a rectangle can be positioned in the origin (0,0) if no other coordinates are provided), or have superclass initialization (e.g., a colored rectangle must redefine all the constructors of its rectangle superclass to add the notion of color). In such cases, the number of constructors increases exponentially in the size of the initialization options, since the initialization approach lacks modularity. We propose a novel approach to field initialization, inspired by the prototypical language Magda. This approach is based on easy-to-compose initialization modules, which result to be smaller compared to classical constructors. Moreover, their number grows linearly in the size of the initialization options. We apply such approach to Pharo, a dynamically-typed object-oriented programming language inspired by Smalltalk. The adaptation to Pharo of Magda’s initialization approach implies solving some new challenges related to moving from a statically typed context to a dynamically typed one.
Directeurs de thèse : Viviana Bono, Stéphane Ducasse Rapporteurs : Oscar Nierstrasz, Aleksy Schubert Examinateurs : Julien Ponge, Elena Zucca
Thesis of the team RMoD defended on 24/11/2017