<< 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:

  1. inversion of control - In a framework, unlike in libraries or normal user applications, the overall program's flow of controlis not dictated by the caller, but by the framework.
  2. default behavior - A framework has a default behavior. This default behavior must actually be some useful behavior and not a seriesof no-ops.
  3. extensibility - A framework can be extended by the user by selective overriding of framework code in order to provide specificfunctionality
  4. non-modifiable framework code - The framework code, in general should not normally be modified by the user. Users can extend theframework, but normally should not modify its code.

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.

Inversion of control

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 1. default display window.

Default display window
Image 1. Default display window.

Create the body of a class

Image 2 shows a screen shot of the PDE with program code showing in the leftmost tab.

Image 2. the pde.

The PDE.
Image 2. The PDE.

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 .

Override setup and draw methods

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.

Questions & Answers

if three forces F1.f2 .f3 act at a point on a Cartesian plane in the daigram .....so if the question says write down the x and y components ..... I really don't understand
Syamthanda Reply
hey , can you please explain oxidation reaction & redox ?
Boitumelo Reply
hey , can you please explain oxidation reaction and redox ?
Boitumelo
for grade 12 or grade 11?
Sibulele
the value of V1 and V2
Tumelo Reply
advantages of electrons in a circuit
Rethabile Reply
we're do you find electromagnetism past papers
Ntombifuthi
what a normal force
Tholulwazi Reply
it is the force or component of the force that the surface exert on an object incontact with it and which acts perpendicular to the surface
Sihle
what is physics?
Petrus Reply
what is the half reaction of Potassium and chlorine
Anna Reply
how to calculate coefficient of static friction
Lisa Reply
how to calculate static friction
Lisa
How to calculate a current
Tumelo
how to calculate the magnitude of horizontal component of the applied force
Mogano
How to calculate force
Monambi
a structure of a thermocouple used to measure inner temperature
Anna Reply
a fixed gas of a mass is held at standard pressure temperature of 15 degrees Celsius .Calculate the temperature of the gas in Celsius if the pressure is changed to 2×10 to the power 4
Amahle Reply
How is energy being used in bonding?
Raymond Reply
what is acceleration
Syamthanda Reply
a rate of change in velocity of an object whith respect to time
Khuthadzo
how can we find the moment of torque of a circular object
Kidist
Acceleration is a rate of change in velocity.
Justice
t =r×f
Khuthadzo
how to calculate tension by substitution
Precious Reply
hi
Shongi
hi
Leago
use fnet method. how many obects are being calculated ?
Khuthadzo
khuthadzo hii
Hulisani
how to calculate acceleration and tension force
Lungile Reply
you use Fnet equals ma , newtoms second law formula
Masego
please help me with vectors in two dimensions
Mulaudzi Reply
how to calculate normal force
Mulaudzi
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, The processing programming environment. OpenStax CNX. Feb 26, 2013 Download for free at http://cnx.org/content/col11492/1.5
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'The processing programming environment' conversation and receive update notifications?

Ask