Code Re-Factoring

As you make changes during the life cycle of an application, code re-factoring is necessary in order to maintain the application specifications in an organized manner. You can use interfaces as a flexible element to help in the maintenance of your application code.

You can define new interface methods that reflect new behavior together with the creation of new code in your application classes. For example, when you add significant and discrete pieces of new functionality to the application, you can use interfaces to keep readability and modularity in the specifications, which are now more complex.

If the new functionality involves the collaboration of several otherwise disjointed classes, instead of adding the new code directly into those classes, you can create new interfaces to reflect the operations required by the new functionally and then implement the interfaces in the existing classes later. This process clearly states in your application that the new code is related to each unit of new functionality.

Another benefit of involving interfaces in code re-factoring is the ability to use interfaces as extra dimensions for code navigation. The JADE development environment provides a number of facilities that enable you to search for references to interfaces, their methods and constants, and the classes that implement them. (For details, see "Maintaining an Interface" and "Displaying all References to the Selected Interface", earlier in this chapter.)