OOP · Why Do We Even Need OOP?
Problems with Procedural Programming
Fahrenheit, and displays the result.
Real-World Examples
1. Calculator
A calculator performs independent mathematical operations such as addition, subtraction, multiplication, and division. Each operation can be implemented as a separate function, making procedural programming a natural choice.
2. Temperature Converter
A temperature conversion application accepts a value, converts it between Celsius and Fahrenheit, and displays the result. Since the workflow is linear and straightforward, procedural programming keeps the implementation simple. A basic banking application can include functions such as:
- Create Account
- Deposit Money
- Withdraw Money
- Check Balance
Each function performs a specific operation, and the program executes them one after another based on the user's choice. For a small banking simulation, this approach is efficient and easy to manage.
Example:
Calculator
Temperature Converter
Simple Banking
Procedural Programming works well for small applications, but as software grows, managing it becomes challenging. Functions become dependent on shared data, making the code harder to understand and maintain. Consider a Hospital Management System. Different functions such as addPatient(),
updatePatient(), bookAppointment(), and generateBill() all access the same patient information. Since every function can modify the data, even a small mistake can lead to unexpected results across the application.
