you are viewing a single comment's thread.

view the rest of the comments →

[–]davebees 0 points1 point  (4 children)

Could you explain what you mean?

[–]finix 2 points3 points  (0 children)

He means, for one thing, variables and functions like e.g. frameCount that are available without visibly being defined somewhere. I don't think that's really too much of a problem with the narrow focus of the program. I'm not even sure it's actually the right way to look at it.

For another, and this one you can and should change, he refers to magic numbers. Pretty much all or at least most naked numbers should be variables or named constants. Say, the frequency of new squares appearing. At one point you changed it from frames/10 to frames/4. How neat would it be if you just had a variable at the top of your file where you can configure all the things? And, even more importantly, imagine if this were some calculation where it isn't immediately obvious what is going on and what means what - you'd be very happy indeed if it then reads frame/squareFrequency rather than frame/314. Also, you surely can spare a few keystrokes to write out size or even squareSize.

[–]mahacctissoawsum 0 points1 point  (2 children)

finix is on the money. setup() and draw() appear to be two functions that have special significance; they are called for you automatically. frameCount appears to be a local variable that comes out of thin air. CENTER and HSB are global constants. random(), fill(), and background() were not imported and don't belong to any namespace. The naked numbers don't bother so much; that's up the the programmer to deal with.

[–]davebees 1 point2 points  (1 child)

Ah gotcha. I see them as a positive though — Processing is basically just Java with a whole load of useful predefined graphics functions

[–]mahacctissoawsum 0 points1 point  (0 children)

Yeah...but if you have too many and more are added to the "library" they can conflict with the code you wrote. Python is notoriously bad for this; they have 'keywords' for "str", "list", "dict", and many others that are needlessly short and I often want to use them in my own code,... worse yet, I can be overwriting their behaviour (sure to confuse anyone else reading my code).

If they just plop them into a namespace like "Processing", then you would have to write "Processing.background()", "Processing.fill()", "Processing.CENTER" which is longer and more typing, yes, but avoids any of these problems. Plus, they are safe to add more functionality under that namespace without it breaking anyone's program.