The Infer Type Refactoring

New

Version 3 is available now. I can handle generics and comes with a preview of all changes, but without the graphical interface (no dependence on GEF!).

Purpose

to decouple classes by deriving and using interfaces

System requirements

What it does

Infer Type is a new Eclipse refactoring that helps you decouple your code. If you have already made use of Eclipse refactorings, Infer Type is best introduced as a sibling to Extract Interface, Generalize Type, and Use Supertype Where Possible. However, it cannot be emulated by any combination of these, and Infer Type may turn out to be just what you need in many cases.

Infer Type is the first Eclipse refactoring that computes a new type for your program. The members of this new type are determined by a program’s use of a declaration element (anything that is declared with a type, i.e., a field, a non-void method, a parameter, or a temporary), where use is defined as everything that is accessed from this declaration element or any other declaration element it might get assigned to (through explicit assignments, parameter passing, or return statements). In brief, Infer Type computes the transitive closure of the use of a declaration element under assignment, as determined by a static program (or data flow) analysis, and constructs the new type from this closure. Also, it redeclares the declaration element with the new type and inserts it (the new type) in the type hierarchy so that all assignments remain type correct. In certain cases, Infer Type will compute and insert more than one new type (this may be necessary to keep the program type correct); in others it will detect that a suitable type is already available and suggest its use instead.

Questions?

If you are in doubt whether Infer Type is at all useful for you, you will find a brief introduction, as well as more advance material here. A quick hands-on example in the context of the Dependency Injection pattern can be found here; it explains much of what you need to know about Infer Type to get started.

Known issues

Installation

Open Source

Infer Type is part of the intoJ project and as such open source. You can check it out here.


© The intoJ Team, 2005.