An order as an object

An order object might hold its number, items, and delivery address. These details are called properties. It might also have methods to calculate a total or cancel the order. Grouping them together can make code easier to understand.

In object-oriented programming, a class is often a template for objects, and an instance is one object made from it, such as a particular customer’s order.

Objects vary by context

Not all objects come from classes or include methods. A JSON object, for example, is a set of named values without actions, much like a map.

Functional programming offers another approach to organising code, with a focus on functions and limiting hidden changes.