Objects#

Objects are constructs that have properties and behaviours. These constructs are often abstractions of real-world objects.

Properties refer to the state of a thing. In a programming context this is the data i.e. variables with types like int, float. This data can also be other objects.

Behaviours are the things that an object can do. Typically this is changing the object’s own properties but can just as easily return a new value or trigger some other action.

Example 1: Rectangle#

Consider a rectangle.

../../_images/rectangle_properties2.png

Properties

  • Height

  • Width

  • Colour

Behaviours

  • Rotate

  • Change dimensions

Example 2: Bank Account#

Consider a bank account as an object

../../_images/full_bank_account.png

Properties

  • Account number

  • Balance

  • Name of holder

  • Interest rate

Behaviours#

  • Deposit

  • Withdraw

  • Calculate interest