I've got a little problem in choosing the best design. I have some (5 at the moment) image processing operations in my coe (Java). Every processing step independent from the other ones and consoists of a small amount of code, 5-15 lines in general. These are mostly wrappers to JAI, AWT and so on.
My current design is an abstract class:
public abstract class AbstractPreProcessingStep {
protected Logger logger = Logger.getLogger(this.getClass().getName());
protected AbstractPreProcessingStep() {
};
public abstract BufferedImage startProcessing(BufferedImage input);
}
Every processing step implements this class and can be called uniform. (like the Strategy-Pattern).
Since every processing step may have a different set of parameters, I created a factory class, like this:
public class PreProcessingFactory {
public static AbstractPreProcessingStep createColorInverter() {
return new ColorInverter();
}
public static AbstractPreProcessingStep createRescaler(float rescaleFactor) {
return new Rescaler(rescaleFactor);
}
public static AbstractPreProcessingStep createEdgeDetector() {
return new EdgeDetector();
}
public static AbstractPreProcessingStep createBlackAndWhite() {
return new BlackAndWhite();
}
...
So, if you want to create a black and white image with inverted colors, you need to do this (pseude code)
bw = PreProcessingFactory.createBlackAndWhite();
inv = PreProcessingFactory.createInverter();
result = bw.startProcessing(result);
result = inv.startProcessing(result);
In my mind, this is a good design since the implementation details are hidden and new processing steps can easily be add by adding a new class.
The other approach which was in my mind was to create a single class with every step as a static method - however, I've got dislike of 'static'
Do you have any suggestions to improve the code?