Skip to content
Kango edited this page Dec 10, 2017 · 7 revisions

Auto-format your code

Use ctrl-t often to auto-format your code in processing. Also save and run often. To run often makes sure you always have a working version, so errors can not grow inside your code.

Order of a Processing sketch

By convention, the order of a Processing sketch is usually:

  • any library import statements
  • any global variables
  • setup
  • draw
  • everything else (functions and classes)

This is true of almost every example in the reference, tutorials, examples, library examples, and most sketches on this forum.

If you have a method that works for you and is consistent, you can use it -- just be aware that others may be very confused reading your code if you put global variables halfway down your code.

Use comments often.

Naming conventions

All class Names start with a Capital like 'class Figure' or 'FigureShape'.

Variables are starting with a small letter: figure. Also, you can write a Capital inside a word if you glue words: successfulfigure is better written as successfulFigure.

Constants are all captial, for glue words with _ : STRENGTH or FIGURE_STRENGTH.

When you have a class Ball and an array or ArrayList of that, note singular and plural: Ball[] balls;

How to post in the processing forum.

Best is to hit ctrl-t in processing first before copy paste into the forum (https://forum.processing.org).

You can edit your post (click the small gear and the 'Edit').

How to format Code:

  • empty line before and after the code section

  • select (highlight) entire code with the mouse

  • hit ctrl-o OR click the small C in the command bar

Clone this wiki locally