On the use of type predicates in object-oriented software: the case of smalltalk

Object-orientation relies on polymorphism to express behavioral variants. As opposed to traditional procedural design, explicit type-based conditionals should be avoided. This message is conveyed in introductory material on object orientation, as well as in object-oriented reengineering patterns. Is this principle followed in practice? In other words, are type predicates actually used in object-oriented software, and if so, to which extent? Answering these questions will assist practitioners and researchers with providing information about the state of the practice, and informing the active research program of retrofitting type systems, clarifying whether complex flow-sensitive typing approaches are necessary. Other areas, such as refactoring and teaching object orientation, can also benefit from empirical evidence on the matter. We report on a study of the use of type predicates in a large base of over 4 million lines of Smalltalk code. Our study shows that type predicates are in fact widely used to do explicit type dispatch, suggesting that flow-sensitive typing approaches are necessary for a type system retrofitted for a dynamic object-oriented language.

[1]  Romain Robbes,et al.  Extensions during Software Evolution: Do Objects Meet Their Promise? , 2012, ECOOP.

[2]  Jonathan Aldrich,et al.  Is Structural Subtyping Useful? An Empirical Study , 2009, European Symposium on Programming.

[3]  Sam Tobin-Hochstadt,et al.  Logical types for untyped languages , 2010, ICFP '10.

[4]  Jing Li,et al.  The Qualitas Corpus: A Curated Collection of Java Code for Empirical Studies , 2010, 2010 Asia Pacific Software Engineering Conference.

[5]  Ralph E. Johnson,et al.  A Refactoring Tool for Smalltalk , 1997, Theory Pract. Object Syst..

[6]  Jonathan Aldrich,et al.  Typestate-oriented programming , 2009, OOPSLA Companion.

[7]  Romain Robbes,et al.  Recovering inter-project dependencies in software ecosystems , 2010, ASE.

[8]  Matthias Felleisen,et al.  Synthesizing Object-Oriented and Functional Design to Promote Re-Use , 1998, ECOOP.

[9]  David J. Pearce Sound and Complete Flow Typing with Unions, Intersections and Negations , 2013, VMCAI.

[10]  Joshua J. Bloch Effective Java, 2nd Edition , 2008, The Java series ... from the source.

[11]  Sam Tobin-Hochstadt Typed scheme: From scripts to programs , 2010 .

[12]  Robert E. Strom,et al.  Typestate: A programming language concept for enhancing software reliability , 1986, IEEE Transactions on Software Engineering.

[13]  Jonathan Aldrich,et al.  Modular typestate checking of aliased objects , 2007, OOPSLA.

[14]  Oscar Nierstrasz,et al.  Object-oriented reengineering patterns , 2004, Proceedings. 26th International Conference on Software Engineering.

[15]  Patrice Chalin,et al.  Non-null References by Default in Java: Alleviating the Nullity Annotation Burden , 2007, ECOOP.

[16]  Robert DeLine,et al.  Typestates for Objects , 2004, ECOOP.

[17]  James Noble,et al.  Implementing a Language with Flow-Sensitive and Structural Typing on the JVM , 2011, Bytecode@ETAPS.

[18]  William R. Cook On understanding data abstraction, revisited , 2009, OOPSLA 2009.

[19]  Premkumar T. Devanbu,et al.  Ecological inference in empirical software engineering , 2011, 2011 26th IEEE/ACM International Conference on Automated Software Engineering (ASE 2011).

[20]  Sam Tobin-Hochstadt,et al.  The design and implementation of typed scheme , 2008, POPL '08.

[21]  David J. Pearce A calculus for constraint-based flow typing , 2013, FTfJP@ECOOP.

[22]  Shriram Krishnamurthi,et al.  Typing Local Control and State Using Flow Analysis , 2011, ESOP.

[23]  Scott Meyers,et al.  Effective C++: 55 Specific Ways to Improve Your Programs and Designs (3rd Edition) , 1991 .

[24]  Emerson R. Murphy-Hill,et al.  Java generics adoption: how new features are introduced, championed, or ignored , 2011, MSR '11.

[25]  K. Rustan M. Leino,et al.  Declaring and checking non-null types in an object-oriented language , 2003, OOPSLA 2003.

[26]  Romain Robbes,et al.  How (and why) developers use the dynamic features of programming languages: the case of smalltalk , 2012, Empirical Software Engineering.

[27]  Eric Bodden,et al.  RefaFlex: safer refactorings for reflective Java programs , 2012, ISSTA 2012.

[28]  Bruno C. d. S. Oliveira,et al.  Modular Visitor Components , 2009, ECOOP.

[29]  Johnni Winther Guarded type promotion: eliminating redundant casts in Java , 2011, FTfJP@ECOOP.

[30]  Martin Odersky,et al.  Independently Extensible Solutions to the Expression Problem , 2004 .

[31]  Mads Torgersen The expression problem revisited: Four new solutions using generics , 2004 .