OOP · Why Do We Even Need OOP?
What is Programming?
You wake up, unlock your phone, and open a food delivery app to order breakfast.
OOP Mastery Roadmap (0 → Hero)
Make students realize the limitations of procedural programming before introducing Object-Oriented Programming.
Imagine a Normal Morning
You wake up, unlock your phone, and open a food delivery app to order breakfast. Within a few seconds, several things happen automatically. The app verifies your login, displays nearby restaurants, checks whether the items are available, calculates the delivery time, processes the payment, and finally confirms your order.
Have you ever wondered how all these tasks happen without a person manually controlling each step? The answer is simple. Behind every application is a carefully written set of instructions that tells the computer exactly what to do. Those instructions are created by programmers and together they form a program.
Programming is the process of designing and writing those instructions so that a computer can solve a specific problem or perform a task. Why Do Computers Need Programming?
Unlike humans, computers cannot think, understand language, or make decisions on their own. Even the most powerful computer cannot perform a simple task unless it receives precise instructions. For example, if you ask a friend to make tea, they already know the process. A computer does not. Every single step must be described clearly:
- Boil the water.
- Add tea powder.
- Add sugar.
- Add milk.
- Boil for a few minutes.
- Pour into a cup.
If even one instruction is missing or incorrect, the result will not be what you expect. Programming exists because computers need clear, step-by-step instructions to complete every task. What is a Program? A program is a collection of instructions written in a programming language that tells a computer how to perform a particular task.
A program can be very small, like printing "Hello World", or it can be as large as an online shopping platform handling millions of users every day. Some common examples of programs include:
- A calculator application
- An ATM system
- A hospital management system
- An online food delivery application
- A railway ticket booking system
Although these applications look different, they all work by following instructions written by software developers. How does a computer execute code?
- Writing a program is only the first step. Before a computer can perform any task, it must understand the instructions written by the programmer. However, computers cannot directly understand Java, Python, or C++ because these are high-level programming languages designed for humans.
- To execute a program, the code goes through a series of stages that convert it into machine language, which consists of binary instructions (0s and 1s) that the processor can execute.
- In Java, the process begins when the programmer writes the source code. The Java Compiler (javac) checks the program for syntax errors and converts it into bytecode. This bytecode is platform-independent, meaning it can run on any operating system that has a Java Virtual Machine (JVM).
- When the program is executed, the JVM loads the bytecode, verifies it for security, and translates it into machine code using the Just-In-Time (JIT) Compiler. The processor then executes these machine instructions and produces the required output.
- This layered execution process is one of the main reasons Java follows the principle of "Write Once, Run Anywhere (WORA)."
Different programming paradigms As software applications became more complex, developers realized that there is no single way to solve every programming problem efficiently. Over time, different programming styles, known as programming paradigms, were introduced. Each paradigm provides a unique way of organizing code and solving problems.
A programming paradigm is an approach or methodology used to design and develop software. It defines how developers structure programs, manage data, and control the flow of execution. Some of the most widely used programming paradigms include:
- Procedural Programming – Organizes programs as a sequence of procedures or functions that execute one after another.
- Object-Oriented Programming (OOP) – Organizes software around objects that combine data and behavior.
- Functional Programming – Focuses on pure functions, immutable data, and minimizing side effects.
- Event-Driven Programming – Executes code in response to user actions or system-generated events.
- Logic Programming – Solves problems using logical rules and facts instead of step-by-step instructions.
Each paradigm has its own strengths, and experienced developers choose the one that best suits the requirements of the application Why there are multiple ways to solve the same problem
Consider the task of developing an Online Library Management System. Regardless of the programming style used, the application must allow users to add books, search for books, issue books, return books, and manage members. One developer might organize the application using functions such as addBook(),
issueBook(), and returnBook(). Another developer might design the same application using objects such as Book, Member, Librarian, and Library. Both approaches achieve the same goal, but they differ in how the software is structured, maintained, and extended.
For small applications, a simple procedural approach may be sufficient. However, as software grows to include thousands of features, multiple developers, and millions of users,