I have a class called HugeClass where the public method addButton() is defined.
public class HugeClass{
public void addButton(){ etc... }
public HugeClass getHugeClass(){ etc... }
...lots of big number crunching logic...
}
There is a class called myController which calls getHugeClass().
public class printController{
...
myController.getHugeClass().addButton();
}
Our client wants us to not call getHugeClass() in printController as the code is very long and eats a lot of memory because it deals with logic in displaying fields on the front end. Is there a better solution?
I am thinking of extending HugeClass to printHugeClass and then call it in printController. Will the performance be better, or will it be the same because it is in-a-way calling the original HugeClass and have to run through the entire parent class as well?
Either
addButtonneeds a properly constructed instance ofHugeClass, and there is no way you can avoid it (subclassing won’t make a difference).Or you don’t need all the details contained in
HugeClassto calladdButtonand it is maybe time to think about splittingHugeClassinto smaller independent components.cf. this post about SRP (Single Responsibility Principle).