Object-Oriented Programming

What is Object-Oriented Programming?

Object-oriented programming (OOP) is programming language modeled around "objects" rather than "actions" and data rather than logic. Object-oriented programming uses a set of separate objects that perform actions and relate to each other to solve a problem or task. Each object is responsible for its own activities and data. So what is an object?

Computing "objects" are modeled around real-life objects, which all have properties and methods. A property may be described as a noun and a method is a verb.

For example, a dog is an object that has certain properties. A dog can also perform actions like running, sitting, barking etc., these are its "methods". Methods are functions associated with an object.

Some of the object properties and methods associated with a dog are:

running dog
  • Properties
  • Breed
  • Colour
  • Eye colour
  • Hungry
  • Length
  • Weight
  • Methods
  • Sit
  • Run
  • Fetch
  • Bite
  • Bark
  • Lay down

How does the 'dot syntax' work?

To access an object, property or method, its reference must include every object that contains it, separated by a dot. This is called the "dot syntax". The hierarchy of objects is represented in code using the dot syntax. A car is another good example of an everyday object and its hierarchy could be coded like this:

myCar.boot.spareTyre

Let's look at some object examples and their associated properties and methods.