Glossary of programming terms

Object:

A collection of data which represents something, and contains information or data about the object.

It can also have methods (see Methods) which can manipulate the objects’ data

Example:

A car=>

  • Colour
  • Make
  • Engine Size
  • Engine Revs
  • DriveCar()

A car has properties (see properties) and DriveCar() is a method operating on the car.

Here, Make, Colour and Engine size are constant but Engine revs is variable as you DriveCar().

Method:

A function (see Functions) contained within an object which can alter values of the object.

Example:

A car=>

  • Colour
  • Make
  • Engine Size
  • Engine Revs
  • DriveCar()

A car has properties (see properties) and DriveCar() is a method operating on the car.

Here, Make is a constant but Engine revs is variable as you DriveCar().

Colour and EngineSize are usually constant once a car is made, but can be changed if need be.

These are often called PseudoConstants.

Function:

A routine which performs and operation on data and can return the result.

A general function may look like this: myfunction( x, y){ return x*y}

Example: function area( width,height){ return width * height}

And to use it: mysquare=area( 30, 40)

So mysquare now equals 1200  (30*40)

In the car example we have a Method called DriveCar(): this is an internal function which does not return anything.

We could have another method function which returns a value: lets add a method GetRevs() and define it as returning the engine revs.

GetRevs(){ return EngineRevs)

MyCar=>

  • Colour=Red
  • Make=Ford
  • Engine Size=1500
  • Engine Revs=0
  • DriveCar( )
  • GetRevs()

So now when we use the new function we will be told EngineRevs:

currentRevs=MyCar=>GetRevs()

currentRevs=10,000 rpm

Functions can also take Arguments (see Arguments), so for example we could define DriveCar to take a speed:

MyCar=>DriveCar( speed )

So we have:

MyCar=>

  • Colour=Red
  • Make=Ford
  • Engine Size=1500
  • Engine Revs=0
  • DriveCar( speed )
  • GetRevs()

And to set car speed we use it thus:

MyCar=> DriveCar( 50 )

Variables and Constants:

A user defined data type which can hold the results of functions or preset value.

In the Car example we have 2 variables Colour and EngineSize. These are both things which a car owner can change or vary.

The Car Make is not changeable by the owner once it has been made, so Make is considered a Constant.

MyCar=>

  • Colour=Red
  • Make=Ford
  • Engine Size=1500
  • Engine Revs=0

These are all attributes of the car.

(Note properties and attributes terms are often used interchangeably)

Attribute:

A property of an object which holds a value.

Example:

MyCar=>

  • Colour=Red
  • Make=Ford
  • Engine Size=1500
  • Engine Revs=0

These are all attributes of the car.

(Note properties and attributes terms are often used interchangeably)

Constructor:

A collection of attributes which instruct object creation.

To create a car you need to have a Car template or Class, then to construct a new Car you can use the basic default Car class and modify it as it is constructed.

Example:

MyNewCar= new Car( Colour=Red, Engine_size=1500, Make=Ford )

So the new car will look like this:

MyNewCar=>

  • Colour=Red
  • Make=Ford
  • Engine Size=1500
  • Engine Revs=0
  • DriveCar()

Here EngineRevs is not set so it takes the default of 0 from the Car class template.