Object-Oriented Programming

2020-09-30

What is an object?

Understanding objects is the key to understanding object-oriented technology. When it comes to software, objects can be broken down into two main components:

  1. State - stored in fields or variables depending on the programming language
  2. Behavior - demonstrated through methods or functions (the nomenclature is also dependent on programming language)

Essentially, an object is a collection of zero or more of these components stored as properties.

So what are properties?

In its simplest definition, a property is an item of data that consists of a subjective name (the key) and some associated content (the value). These items of data are most commonly referred to as key:value pairs. For example, a key might be sport and its value football. But values aren't limited to just strings or numbers - they can become very powerful with functions!

But why objects?

Software objects allow for the internal state of an object to be contained. Any interaction that is going to take place with the object has to be done through the object's functions. This principle is known as data encapsulation and is an important concept in object-oriented programming.

Consider the real-world object of a car as a software object:

We can store it's state (current speed, current velocity, current gear, current gas tank level) internally in variables, along with defined functions that can change it's state. Because everything is stored within the object, the object has the ability to govern how it is allowed to be used and changed.

want to get in touch?