my english is not good enough for a tutorial,
but i have a idea about a
good practice beginner info sticky
revisioning
it could be a good idea even for small tests to start with a revisioning system
easy just as some comment lines // rev 0.77b
and some info what you changed, what you published ( like here to a forum post )
or even show it in the header ( window title )
example
/*
use a longer description for your project:
_____________________________________________________________
here want test a basic layout of a processing sketch
using a revision number system
_____________________________________________________________
also the usual info about file(s):
/revisioning/revisioning.pde
/revisioning/data/optional data files like images, fonts, data csv...
means you can only "distribute" as zip of the
/revisioning/ directory
_____________________________________________________________
and optional info about copy left:
https://www.gnu.org/licenses/copyleft.en.html
kll-engineering
01/2019
[ CC BY SA ] https://creativecommons.org/licenses/by-sa/4.0/legalcode
or Public Domain [PD]
[ CC0 ] https://creativecommons.org/publicdomain/zero/1.0/
_____________________________________________________________
and a revision list:
*/
// v0.0 start this
// v0.1b internal revision / tests
// v0.1 public rev : posted at forum
String rev=" v0.1";
// canvas window layout:
String mytitle="my project";
int mywidth=500, myheight=500;
// animation:
int cr=0; // ellipse radius see mouse wheel
void settings() {
size(mywidth, myheight);
}
void setup() {
surface.setTitle(mytitle+rev);
println("canvas: "+width+" * "+height);
println("operational concept: \n key :\n mouse : wheel -> radius");
// static look
fill(0, 200, 0);
stroke(200, 0, 0);
strokeWeight(width/20);
cr = width/2; // ellipse radius setup
}
void draw() {
background(200, 200, 0);
ellipse(width/2, height/2, cr, cr);
}
void keyPressed() {
println("key "+key+" keyCode "+keyCode);
}
void mousePressed() {
if ( mouseButton == LEFT ) {
println("LEFT");
}
if ( mouseButton == RIGHT ) {
println("RIGHT");
}
if ( mouseButton == CENTER ) { // hardware and OS dependency
println("WHEEL");
}
}
void mouseWheel(MouseEvent event) {
float e = event.getCount();
cr += e; // hardware and OS dependency
println("e "+e+" radius "+cr);
}
/*
if you want this to be the template to come up
when you start (a new) processing sketch pls. save it as
/sketchbook/templates/Java/sketch.pde
*/
template
it might be not too much used,
so possibly you felt bad already
that a new sketch comes up empty and you have to type the defaults again and again https://github.com/processing/processing/wiki/Templates
the idea is to save a good prototype / like above code example / as a template to
/sketchbook/templates/Java/sketch.pde
backup
YES make backups!
we all learn the hard way when loose some code, projects, OS installations or hard drives…
and also about processing ( or arduino projects ) i have tried many ways:
“save as” MyProject_v02
can help to save each revision under a different name,
but if all works well you end up with a lot of project entries you never use again
so possibly better first make a sub directory for each project in development??
zip it away
now you can zip a project or the whole sketch dir
and you can save that even to a other drive or computer ( daily ? )
but that is only part of the story,
what if you want to work on 2 computers ( but same project )
i have tried to have the sketch dir on a USB stick ( worked well for 2 years )
( so actually had no backup but available on ?every? computer )
run google drive on windows and have the sketch dir on it
so automatic backup and availability even in a “remote” team
but after 3 years i had 9000 files and 3GB usage on google drive and the
boot of the old PC was delayed 5min?
a cleanup by “move to zip” did actually not help too much
( by zip to PC and reset will loose all the original google files ( spreadsheets… ))
so i think for above 3 points there is a lot of knowhow with the experts
i hope they want to share.
On the Mac I have found it very helpful to use the Notes app to do something similar.
At the top of each .pde file I add a comment like “// filename” and append numbers and letters for revisions and just paste it to a new Note.
Then when things are working well in a sketch and I’m about to start making changes that might not be successful, I make a new Note and paste the sketch in there. If the changes work okay, I might change the name a bit in the comment do differentiate it, but I don’t necessarily have to actually rename the .pde file. If I want to go back to a previously working version, just find the Note, and copy/paste all the code back into the .pde file.
One downside is that code in tabs might be a bit difficult to manage in this way.
Some advantages are that Notes are attached to iCloud and easy to access from multiple computers, it’s easy to group Notes into folders and yet still see a list of all Notes without looking through all the folders, it’s easy to search for a note with any text string which can be a snippet of code or a comment in the code, etc. Also, they can be sorted by Date Created, Date Modified, or Title which is essentially the first line in the Note, and essentially the .pde file name if the first line is “// filename.”
You can have piles of history for a sketch always accessible without having piles of sketch folders and directories that have to be backed up and maintained.
I don’t know if there’s something like this in Widows or Android, but I have found it works great in Mac.
E.g. when you have a class Particle you don’t want to use a for loop inside of it to display all the particles.
Or you don’t want to use from a class an object that is situated at sketch level.
Like a long FAQ for common programming problems? With a Classes section, and an entry “Don’t loop over objects inside an object” that people can then directly link to when giving forum feedback…?
I‘d say that would be a good idea. Using your example of a particle class, you‘d check for for loops within a class that goes over other instances of that class in a global variable… or just checks for accesses to global variables from within classes (would probably make more sense and still work in this case)…
Although then things like mousePressed would probably return „unclean“ if used in classes… and generally using processings methods in classes should also be as unclean (as far as i know)…
Oh well, maybe that could be avoided by having exceptions… but that‘s gonna be a Long list (pretty much all classes/variables that are not self-written)…
I feel it’s going a bit off topic from kll’s original idea, which seems to be guidelines for managing sketches if I understand correctly, but nonetheless interesting suggestions and ideas.
Responding to what’s being discussed right now, I think the best location for guiding beginners through the basics is when they open Processing for the first time. I’m assuming that most (absolute) beginners simply use their search engine and end up on the download page, followed by installing and opening Processing. At his point most of them are probably unaware of the reference page, the tutorials, our forum, the implemented examples, etcetera.
I’d say that if you want to make them aware of the information that’s already out there, this would be the perfect place for it.
Another idea would to make a library* with examples of questions/problems we often encounter on this forum. For instance, an example which clearly explains the difference between global and local variables. Or a sketch that clearly shows a proper structure of a sketch, including explanations why it’s good to structure it that way.
EDIT *
Library might not be the right term, I meant PDE examples (thanks kll for pointing it out)