Unit 1
Unit 1
Example: Changing the behavior of the Student class does not affect
the Library class in a school management system.
Allows different classes to use the same method name but with
different behaviors.
Dynamic binding and abstraction add extra processing, making OOP slower
than procedural programming.
Example: A simple C program runs faster than a similar Java OOP program.
May not be suitable for real-time systems.
4. Increased Complexity
Small programs do not benefit from OOP since structuring everything
into objects increases unnecessary complexity.
Example: A simple calculator program does not need Calculator and
Operations classes.
Overhead for simple tasks.
Encapsulation in OOP
The object model allows software to map real-world entities into classes
and objects.
Example: In a Library System, objects like Book, Member, and Librarian
represent real entities.
Useful for complex applications like ERP systems, banking software, and
e-commerce platforms.
It helps organize, structure, and manage large codebases.
3. Multi-Developer Projects
When multiple teams work on the same project, an object model provides a
clear structure and guidelines.
Helps in better collaboration by defining object interactions.
OOP allows classes to inherit properties and methods from existing classes,
reducing redundancy.
Example: A Car class can inherit from a Vehicle class instead of redefining
common attributes.
Changes in one part of the code do not affect the rest of the program due to
modularity.
Example: Updating the Student class does not affect the Library class in a
school management system.
class BankAccount {
private:
public:
};
class Car {
public:
private:
};
Users call start(), but they do not see how the engine works
internally.
Real-World Example:
A TV remote exposes buttons (volume up/down, power), but the user does
not need to know the internal circuitry.
3. Inheritance (Code Reusability)
Inheritance allows one class to derive properties and methods from another
class.
class Animal {
public:
};
int main() {
Dog d;
Dog inherits the eat() method from Animal without redefining it.
Real-World Example:
A Car class can inherit from a Vehicle class, reusing common properties
like wheels and engine.
public:
public:
};
public:
};
Real-World Example:
A draw() function can be used to draw both Circles and Rectangles, each
with its own implementation.
3. Additional Object-Oriented Principles
Designing a Hospital
Represents classes, attributes,
Management System showing
Class Diagram methods, and relationships
Doctor, Patient, and Appointment
between them.
classes.
States of an "Order" in an e-
State Machine Represents different states of an object
commerce system: Placed →
Diagram and transitions.
Shipped → Delivered.