Home | DMP | Project | Journal | Contact
Relevant Java Classes | Delete Call Site | Template Call Graph | Research | Final Report
Previous (Type Classification)
Next (Type Inference Algorithms and Call Graph Construction)

Polymorphism is one of the most important features of object-oriented languages. It can be easily described in terms of abstract and concrete types; Agesen defines it as the ability of code to work on objects of different concrete types, as long as the abstract type required by the code is satisfied. For example, instances of HashSet and TreeSet may be used interchangeably in program contexts expecting a Set, regardless of which set implementation the programmer had in mind when writing the code. (See the Java tutorial on Collection implementations for more information on these classes.) Through this expressiveness, polymorphism lends itself easily to code reuse and increasing levels of abstraction for the programmer. In the words of Joshua Bloch, author of the tutorial for the Java Collections Framework:

"As a rule of thumb, you should be thinking about the interfaces rather than the implementations...For the most part, the choice of implementation affects only performance. The preferred style...is to choose an implementation when a collection is created, and immediately assign the new collection to a variable of the corresponding interface type (or pass the collection to a method expecting an argument of the interface type). In this way, the program does not become dependent on any added methods in a given implementation, leaving the programmer or maintainer with the freedom to change implementations at the drop of a hat."
Polymorphism is often used in this capacity in Java (and, I would assume, in most other object-oriented languages), with the FLEX source files providing many examples. Despite its benefits - flexiblity and expressiveness - polymorphism can become quite a challenge for type inference, especially with a concrete and specific system. Agesen's Cartesian product algorithm described in the following section directly tackles many of the problems presented by parametric polymorphism, the ability of a method to be invoked with arguments (including the receiver) of multiple concrete types.




Home | DMP | Project | Journal | Contact
Relevant Java Classes | Delete Call Site | Template Call Graph | Research | Final Report
Previous (Type Classification)
Next (Type Inference Algorithms and Call Graph Construction)

©2002, Katie Heise