B3.1.1 · OOP for a single class
The OOP paradigm
By the end you can
Contrast procedural programming and OOP, explaining how objects encapsulate state and behavior.
As software projects grew to hundreds of thousands of lines of code, procedural programming (centered on standalone functions operating on detached global data) became error-prone and hard to maintain. The paradigm solved this by modeling software after real-world entities that encapsulate both data and actions together.
Classes versus objects#
The distinction between a class and an object is fundamental to OOP:
- : The blueprint, template, or schema written by the programmer. It defines what properties an object will have and what operations it can perform, but allocates no object memory itself.
- : A concrete, living instance created from the class blueprint using the
newoperator. Each object has its own separate memory allocation on the heap and maintains its own private values (its state).
Analogy: An architectural blueprint for a house is a class; the physical houses constructed on a street from that blueprint are objects.
Procedural versus Object-Oriented paradigm#
- Procedural: Top-down design. Programs are divided into functions and procedures. Data is passive and passed into functions as arguments. High risk of side effects from unexpected mutations of shared data.
- Object-Oriented: Bottom-up modular design. Programs are networks of interacting objects. Data is active: objects manage their own state and communicate by passing messages (calling methods on each other).
Check yourself
OOP foundations
Quick questions, made fresh every time and marked here. Do a few until they feel easy.
Exam practice
Paper 1-style questions
3 questions · 9 marks
Write your answer as you would in the exam, then show the mark points and tick each one your answer made. These are our own questions in the style of the exam, not past-paper questions.
1.Compare procedural programming and object-oriented programming (OOP) in terms of data-function coupling, code organization, and state management.
[4]Compare: Similarities and differences, about both things, point by point.
2.Distinguish between a class and an object.
[2]Distinguish: Make the differences between two things clear.
3.State three core principles or characteristics of the object-oriented paradigm.
[3]State: Give a short answer, no explanation needed.
In a nutshell
- Object-oriented programming (OOP) organizes software into self-contained objects bundling state (attributes) and behavior (methods).
- A class serves as the abstract blueprint, while an object is a concrete instance allocated in memory.
- Procedural programming separates functions from data, whereas OOP encapsulates data and methods together.
- Core pillars of OOP include encapsulation, inheritance, polymorphism, and abstraction.
