I have a very large and bloated class and I want to split it into separate files, but it should be completely transparent to the user and compatible with existing projects that use the class.
In particular, I have my own ImageMatrix
class and it defines a ton of unary functions, a ton of binary functions with a scalar, a ton of binary functions with another image, etc. To keep the class clean and maintainable, I wish to put each class of operators in a separate file.
Is there a way to just cut/paste these methods into a file and include them in the source?
So I wish that I can still do this, but the methods actually reside in different files:
ImageMatrix img = new ImageMatrix(800, 600, 3);
img.clear(0.5f, 0.0f, 0,0f);
img.addSelf(anotherImg);
img.normalize();
img.abs();
img.addSelf(0.5);
Each method is around 15-30 lines of code because the implementations are extremely optimized for performance, the like of which is impossible to achieve with Bufferedimage or even a plain int[]. There is a lot of code duplication, which is the main reason to group similar methods together. If I add a function or if I change global behavior (like error checking), I can easily keep things coherent.