50 cards
Object-oriented programming rests on four foundational concepts that together shape how we model and organize software. Encapsulation is the practice of bundling data and the methods that operate on that data into a single unit, typically a class, while restricting direct access to some of the object's components. By h...
The SOLID principles, introduced by Robert C. Martin (often called Uncle Bob), are five design guidelines that together promote maintainable, flexible, and testable object-oriented software. The Single Responsibility Principle states that a class should have only one reason to change, meaning it should have just one jo...
At the heart of OOP lies the distinction between a class and an object, and the related idea of object identity versus equality. A class is a blueprint or template that defines attributes and behaviors, while an object is a concrete instance of that class created at runtime. The analogy of an architectural plan versus...
Beyond the structure of individual classes, object-oriented systems are defined by how objects relate to one another. Association is the most general form of relationship, where one object uses or interacts with another without either owning the other. A Teacher and a Student, for example, are associated because they i...
Polymorphism in object-oriented programming is enabled by two distinct mechanisms known as overloading and overriding. Method overloading, the form of compile-time polymorphism, occurs when multiple methods share the same name but differ in their parameter lists within the same class. For instance, a class might define...
Abstraction in OOP is most often expressed through abstract classes and interfaces, two related but distinct constructs. An abstract class is one that cannot be instantiated and may contain both abstract methods without implementation and concrete methods with full behavior. A typical Java example declares an abstract...
Both composition and inheritance are ways to build classes out of other classes, but they capture fundamentally different relationships. Inheritance models an is-a relationship, as in Dog is an Animal, while composition models a has-a relationship, as in Car has an Engine. The widely cited principle to favor compositio...
Beyond the SOLID principles, several general design principles guide object-oriented programming toward clearer, more maintainable code. The DRY principle, Don't Repeat Yourself, holds that every piece of knowledge should have a single authoritative representation in the system. Copy-pasted logic, duplicated validation...