QamoosTech
Programming FundamentalsObject-oriented programmingBeginner

Object-Oriented Programming (OOP)

PronunciationOB-jekt OR-ee-en-ted PRO-gram-ing

Definition

Object-oriented programming (OOP) organises code around objects that combine data and the behaviour that works on it, created from classes.

Where you hear it

In almost every programming course, design discussions, and interviews that ask about the pillars of OOP.

Examples

  • We modelled members and payments as objects, each with its own methods.
  • The four pillars of OOP are encapsulation, abstraction, inheritance and polymorphism.
  • The invoice and the payment are classes, and each payment object knows how to validate itself.

Common mistake

Forcing everything into classes. Simple data and plain functions are often clearer than a deep class hierarchy.

Don't confuse with

Functional programming, which builds programs from pure functions and plain data instead of objects that change.

Say it at work

  • In a meeting or chatLet's keep the design simple: a couple of classes, no deep inheritance.
  • In an email or ticketOOP fits well here because the entities have behaviour.