<< Chapter < Page | Chapter >> Page > |
A software framework, in computer programming, is an abstraction in which common code providing generic functionality can be selectivelyoverridden or specialized by user code providing specific functionality.
Frameworks are a special case of software libraries in that they are reusable abstractions of code wrapped in a well-defined API, yet they contain some keydistinguishing features that separate them from normal libraries.
Software frameworks have these distinguishing features that separate them from libraries or normal user applications:
In short, a software framework is a computer program that helps you to write computer programs.
The Processing PDE fits all of these characteristics of a framework.
By default, the overall flow of control of a Processing sketch is beyond the control of the programmer. When the sketch starts running, the setup method will be called once and (by default) the draw method will be called repeatedly at a default rate of 60 calls per second.
A small window will be displayed in the default Java display mode. If you haven't overridden the draw method to control the contents of that window, it will look something like that shown in Image 1 .
Image 2 shows a screen shot of the PDE with program code showing in the leftmost tab.
When you create a new sketch in the PDE and enter code in the leftmost tab, you are actually writing the body of a new class witha class name that matches the name of the tab. The code that you see in Image 2 , for example, constitutes the body of a new class named Cars .
In general, you need to override the methods named setup and draw in the body of this class. It is the code that you write in these two overridden methods that controls the behavior of the sketch.
The setup method will be called once when you click the run button. You should place any code that needs to be executed to initialize the state of the sketch in this method. Often this code willinitialize variables, instantiate new objects, etc.
After that, by default, the draw method will be called repeatedly until you terminate execution of the sketch. You need to write codein the draw method that controls the ongoing behavior of the sketch. Often, this code will call methods on existing objects, modify thecontents of variables, instantiate and call methods on new objects, etc.
Notification Switch
Would you like to follow the 'The processing programming environment' conversation and receive update notifications?