We're looking at ways of making PixelMapGen more flexible, particularly when it requires more data than width, height, and AffineTransformType.
One way we could refactor: define an interface to implement, instead of an abstract class. Then different classes could have different constructors.
Another possibility: The constructor initializes local vars for width, height, and AffineTransformType but does not call validate(). The generate() method calls validate() and lets you know if you are missing data. You can also call it yourself outside generate(), of course. We could put the call in the abstract class generate() method, which will then have to be called in the first line of child class generate() methods.
These approaches can be combined, of course. They might move us towards a Factory Method design pattern, too, but I am not sure that is necessary, especially in fairly light weight coding environments such as Processing.
We're looking at ways of making
PixelMapGen
more flexible, particularly when it requires more data than width, height, andAffineTransformType
.One way we could refactor: define an interface to implement, instead of an abstract class. Then different classes could have different constructors.
Another possibility: The constructor initializes local vars for width, height, and
AffineTransformType
but does not callvalidate()
. Thegenerate()
method calls validate() and lets you know if you are missing data. You can also call it yourself outside generate(), of course. We could put the call in the abstract class generate() method, which will then have to be called in the first line of child class generate() methods.These approaches can be combined, of course. They might move us towards a Factory Method design pattern, too, but I am not sure that is necessary, especially in fairly light weight coding environments such as Processing.