Recently I've been looking at Povray, pyprocessing, and cfdg (version 3.0) as tools for creating digital images. I have branched two separate blogs where I mainly explore jruby + processing and processing.py

Saturday, 24 January 2009

Processing Idioms

Processing is still pretty new, and still evolving, but I think it can be quite useful to present our book readers with some guidance toward coding idioms. It is quite possible in processing to mix and match code that has a very procedural feel such as defining the fill(255, 0, 0), then create a new instance of shape (say Saucer in my case), which will then be rendered using the color defined by the fill statement. When I started this project this seemed to be idiomatically correct, but now I've got some misgivings. On looking at the code from Daniel Shiffman and others, I think I am leaning toward the alternative, a more object oriented approach of giving the object a render() function, and also a setColor() function. I would be interested to know what anyone else thinks, but for the moment that the way I am thinking of going....
I would very much like some response, because I am sure that when the project was conceived just writing a book chapter in isolation could not have been what Darrel intended, and it certainly wasn't the idea that attracted me to participate in the project (flame flame).

2 comments:

  1. Hi

    I would say it is a good idea to standardise on a class interface for drawing the main thing of interest in a particular example, eg with a render() method as you suggest. That way it would be easy for the reader to lift code examples, or to combine examples from different chapter in a new sketch. The only trouble is I guess object orientated programming isn't covered till quite late in the book.

    b e n

    ReplyDelete
  2. Thanks for the comments Ben, I had a faint hope that I could stimulate a bit of discussion here. My bit of the book is after classes have been introduced so I don't see that as a problem. I'm fairly drawn toward the OO approach, but I also like the terse syntax of the procedural type commands fill() etc. If it were Python there would probably be only one way to it, perhaps its nice to have the choice/dilemma.

    ReplyDelete

Followers

Blog Archive

About Me

My photo
Pembrokeshire, United Kingdom
I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2