Challenges with static methods

There have been a few questions about static methods with processing IDE. Because everything in Processing IDE is nested code static methods can be used only with static classes (Questions on static methods).
So are there options to circumvent this? Yes there is. As @GoToLoop explaned here Deeply-layered nested classes

You can move the class to regular .java file instead of .pde residing inside Processing IDE. You will lose compiler support from Processing IDE and most likely that code should be developed in external IDE like Eclipse.

Second option is to use a wrapper class. It’s not an optimal solution, but it can be done inside Processing IDE. Wrapper wraps around the target code and gives additional access methods. Wrappers have been used to simplify access. In this case they are used to store what in standard Java code would be in static variables and methods.

The statement above is not entirely correct. You can define your .java helper files and Processing will not transpile those files. You still need to have a PDE file and the name of this file needs to match the name of the folder containing this file. You can still write pure Java inside this PDE if you know what you are doing.

Kf

1 Like