Object-oriented programming (OOP) organizes software as self-contained objects that pair data with behavior. This can keep changes to one part of a system from breaking another, especially when the system must handle new kinds of things over time. section 3.8
Four ideas help make objects flexible and modular:
- Encapsulation keeps an object's data and the methods that manage it together, shielding internal state behind a public interface. section 3.4
- Abstraction exposes essential features while hiding implementation details, like taking a photo without managing the camera's inner workings. section 3.4
- Inheritance lets a new class take properties and methods from an existing class, then add its own features. section 3.4
- Polymorphism lets different objects respond to the same operation; classes and virtual methods helped establish this approach. section 3.4 section 3.8
A changing hospital simulation
In Simula, Patient objects could carry their own data and behavior. A TreatmentRoom could handle different patient classes, and a new EmergencyPatient type could be added without changing the room's code. section 3.8
Figure 3.3 OOP principles in picture form.

A visual summary of the OOP principles. section 3.4












