Good practice / revisioning / template / backup

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.

3 Likes

Thanks for sharing this.

Do you mean, revise this into a sticky post on the forum ā€“ or as entries in an FAQ?

who ever works on tutorials or any "using processing ā€œintroā€ "
what reaches beginners might pls. think of that points.
( and translate it, LOL )

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.

2 Likes

thanks,
as i use windows or RASPBIAN i search for a google tool,
and found ā€œgoogle KEEPā€
https://play.google.com/store/apps/details?id=com.google.android.keep&hl=en ,

wondered if i need to install something on win ( no, its a browser app )
on android can add install it as app

so i started it and WOW see a nice picture i put there 2014
with a so-called checklist ( test )
! and never used it again. LOL !

so i will try your idea and check it out for coding
( snippets )

for organizing i only see a label feature?


What I like is some guidance to clean code.

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.

3 Likes

good, but in what form you want to ā€œtransportā€ ? ā€œteachā€ that?
the https://processing.org/reference/class.html

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ā€¦?

3 Likes

Yes, thatā€™s it.

Is there a tool that makes a quality check and gives you feedback about the architecture of your Sketch?

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)ā€¦

good points, thank you,


how about we stop preaching beginners, who not yet learned about

  • variables
  • functions

that they should start with classesā€¦


again, where we do this best?
processing FAQ and WIKI not,

  • reference/class.html
    ok, or should have a link to it.

https://processing.org/examples/
section objects ?

or stay within the forum? good place:
https://discourse.processing.org/c/teaching


also i think it should not begin with

  • how to write classes

better start with when and why use classes.

1 Like

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)

4 Likes

I have been trying Working Copy and I probably will not go back to using Notes, as I mentioned previously. Its only for iOS though.

Wait, can you also use that like the iCompiler??

It doesnā€™t directly integrate with iCompiler, but you can copy/paste into Working Copy and keep sketches in Github easily.

1 Like

Ah ok, so itā€˜s not possible to run the code. Oh well :sweat_smile: wouldā€˜ve been nice if it was possible.

Just a repository manager.

1 Like