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.
IndexProcessing DevelopmentLibraries,  Tool Development › OOP framework for Processing
Page Index Toggle Pages: 1
OOP framework for Processing? (Read 2142 times)
OOP framework for Processing?
Aug 9th, 2009, 9:12am
 
Hello,

How about giving Processing an object-oriented programming framework, which would guide and help developers to produce reusable code, separate modeling logic and scene drawing as in MVC (Model-View-Controller) pattern, and easily implement other design patterns?

Maybe some work has been done already in this direction?
Re: OOP framework for Processing?
Reply #1 - Aug 9th, 2009, 4:33pm
 
Well, I have two objections to the suggestion:
1) Processing aims (mostly) at newbies and goes to great lengths precisely to avoid OO and offer a procedural way of doing things, more simple and intuitive to beginners.
2) It is based (as you know, of course) on Java which is already OOP-oriented, and if Processing hides it (more or less), it doesn't prevent using it (ie. classes and such). So the OOP side is already there.

Now, I am actually not against the proposal, just curious how such "framework" would look.
After all, one can apply these design patterns to their own code, no?
And they would be useful mostly for the most complex sketches, lot of what we do is quite small and won't use such schema.
Re: OOP framework for Processing?
Reply #2 - Aug 10th, 2009, 3:51am
 
By "framework", I was thinking of something like Zend Framework for PHP. Something that would just guide you through creating well-structured code.

For example, newbies (and others) often mix modeling logic and scene drawing in the draw() loop. I think it is mostly inappropriate. Let's take an example, say you want to move objects and render them on screen. Often you see things like :

Code:
void draw() {
 for (int i = 0; i < balls.length(); i++) {
   balls[i].move();
   balls[i].display();
 }
}


Modeling logic (moving the balls) and scene drawing (displaying the balls) statements are all mixed in the same loop. If your modeling logic gets more complicated (say, you want the balls to bounce on each other) then the code above is not the easiest to start from. It is much better to start with something like :

Code:
void draw() {
 model();
 view();
}

void model() {
// modeling stuff
 for (int i = 0; i < balls.length(); i++) {
   balls[i].move();
 }
}

void view() {
// rendering stuff
 for (int i = 0; i < balls.length(); i++) {
   balls[i].display();
 }
}


Sure, you don't need a framework to build a simple application. You don't even need it to build well-structured code or to implement a design pattern, but it's easier to do so with some guidelines (especially if you are a new to programming).
Re: OOP framework for Processing?
Reply #3 - Aug 10th, 2009, 1:12pm
 
Hi guys, I agree with both of you, so here's my 2 cents:

I've used Zend, Struts and Cocoon on some big projects, so I feel entitled to have my say here. These projects were without exeption commercial projects. I started by modelling organizational structures and proceeded to building my objects, just by the book. This is an approach that is well suited to dayjob moneymaking stuff.

On other occasions, I worked with artists, at waag.org and tesla-berlin.de, and I quickly and painfuly discovered that artists have their own methods, partly learned at art school, partly deeply personal. You just can't get a decent software specification for a work of art. Working with artists is an immersive experience that nullifies a decade of good software development, it's like a second childhood (and you can imagine what kind of boy I was).

So IMHO a domain specific language like processing is the best approach to making software engineering accessible to artists, mega kudos to Fry and Reas for discovering this.

OK so what happens when the project is just too complicated and needs a professional programmers touch? I think a MVC tutorial would certainly be nice to have. Particularly the Observer/Observable pattern is really cool for handling events, and the Pipes and Filters pattern is great for handling data streams. Just keep in mind that one of the prime target audiences of processing are artists, and that they definitely do have their own methods and goals, as strange as they may seem.
Re: OOP framework for Processing?
Reply #4 - Aug 10th, 2009, 6:24pm
 
This thread scares me a bit.

A Design Pattern is a guide, yet this is sounding like you are taking it VERY literally.

I would suggest reading this document if your only real knowledge of MVC is from Wikipedia and web application development frameworks  http://martinfowler.com/eaaDev/uiArchs.html.

I would hope if there was a philosophical belief that processing should teach people to program, that it would teach them to program, not just adopt some fashionable paradigm.  You can tip any set of rules into a mans mind, but he must understand them for any value to come of it.  For me, the occurrence on the web of MVC seems like some kind of rote-learned good-idea.

Sorry for the rant  Lips Sealed.
Re: OOP framework for Processing?
Reply #5 - Aug 11th, 2009, 2:31am
 
Discussing this shouldn't scare anybody ;-) and sorry if I misused the word MVC, that was just to give an example, but maybe it was a bad one. Undoubtly, framework was a bad choice too.

Alvaro's idea of tutorials is nice. Expanding the learning section is maybe the best choice.

In some cases, when you're stuck with the procedural syntax, a little bit of OOP or design patterns knowledge is enough to solve your problems. That would be great to share our best pratices so everyone could benefit from it.
Page Index Toggle Pages: 1