I’m confused and the more I google the more confused I get, so I better ask here
As me and my son study Processing im now trying to document our progress and I don’t know If i’m suppose to write that we are looking at a function, method or event most of the time.
This is what I guess:
Is a function only another word for method when you call it from a class like, buss.moveThatBuss()
Is a method everything you create starting with “void” like, void moveThatBuss()
Is event already existing “void’s” like, void mousePressed()
In what category does for example “fill()” and “rect()” fit in?
Where does “setup()” and “draw()” fit in?
And “if else”, is this a function method or event?
What about loops?..
As you can see… I’m confused about how to categorize stuff. What more categories is there?
I’ve read multiple articles, guides, forum posts and also of course looked at Shiffman on Youtube and his book “learning Processing 2nd edition”.
People are using the terms differently, what is correct?
The Processing (default Java mode) documentation describes programming with functions, some of which are built in, and some of which may be called automatically in various ways by a running sketch (like settings(), setup(), draw(), and the event handlers). All these top-level entities are called “functions” in Processing documentation – and the ones you write yourself are also functions,
Some of these Processing functions are also methods – that is, they belong to built-in classes within Processing. Examples are IntList.append(), PVector.lerp(), Table.addRow() – these are functions, but functions attached to a specific class or instance object: methods. When you create a String object in Processing and call .equals(), that is a method – it belongs to the String.
The wrinkle is that Processing is compiled under-the-hood into Java. Almost everything that Processing presents as a top-level a “function” ultimately in Java becomes a method of a PApplet object – your sketch. So, at run-time, everything is only methods on objects–mainly methods on one object, PApplet. If you click from any Processing reference page over to the JavaDoc and look up PApplet, you will see that a large portion of the Processing language functions are actually a set of methods on that one object.
This is helpful to know when communicating with programmers coming from (or heading into) the Java world. In fact, in Java documentation everything is always described as a “method” (all subroutine functionality is always connected to some class or object) and never a “function” – formally you don’t use the word “function” at all. This is good to know when you encounter people who are primarily Java programmers, for example on StackOverflow – when they say “method” (like “the draw() method”) they are referring to what a Processing tutorial will refer to as a “function” — anything anywhere in your sketch that takes an argument and returns a value.