refactoring advice


I have a class similar in structure to this sample one:

public class Foo {
public ItemList getItemList();

throughout the project's code (and the codebase is very large), there are calls like:

foo.getItemList().add(arg1, arg2, arg3);

this actually exposes some functionality that should stay private and stands in the way of my overhauling the class's implemention. I'd like to change the class's interface to be:

public class Foo {
public void addItem(param1, param2, param3);

and the code to add an item to be

foo.addItem(arg1, arg2, arg3);

Is there a refactoring method or something else in IDEA that would allow me do this without much pain and suffereing?


1 comment
Comment actions Permalink

I've never done this, but it should work. Create the addItem method, including setting it's body to the logic you wish to encapsulate. Then do "Replace method code duplicates", with scope chosen as the entire project.

--Dave Griffith


Please sign in to leave a comment.