We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Processing.org libraries and PApplet instanse issu
Page Index Toggle Pages: 1
Processing.org libraries and PApplet instanse issu (Read 351 times)
Processing.org libraries and PApplet instanse issu
Mar 23rd, 2010, 4:54pm
 
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?
Page Index Toggle Pages: 1