Ignotus-mago / PixelAudio

PixelAudio maps arrays of audio samples onto arrays of pixel values.
Other
0 stars 0 forks source link

Refactoring PixelMapGen #18

Open Ignotus-mago opened 3 months ago

Ignotus-mago commented 3 months ago

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.