hi guys
i have a pattern design problem
every time i use a liberaries (osc5, Serial, Arduino, GSVideo. etc..)
i am forced to declare an instance in main PApplet for costructor of libraries and handle callbacks there.
this is ok for little test from sketches. ok, but
when i am in eclipse for a big project i need more flexibility.
i make a component based classes that - for example - poll serials and use a lot of delegation or bad use of singleton-like stuffs to forward the callback i recive in PApplet.
when it will need only something like:
Code:
class MyApp extends PApplet {
...
mySerialComponent = new SerialComponent()
...
}
class SerialComponent implements ISerialEvent{
...
private Serial device = new Serial(this);
...
public serialEvent() { ...handle event... }
}
class Serial {
Serial(ISerialEvent parent) {
//constructor
this.parent = parent
}
... //ohu, there is a new event!
...parent.serialEvent()
...//is what it really happend inside processing.org framework
}
interface ISerialEvent{
public SerialEvent()
}
adding a simple interface would be simpler and clean when design application in OOP mood, isn't it?
ok this is my dream.. bytheway
which is the cleaner way without external interface?