📝 Topics Covered
- 1. Paradigms & The Architect’s Tool
- 2. Classes and Objects
- 3. Class Relationships
- 4. Inheritance and Polymorphism
It is crucial to understand how each of the programming paradigms works and how they guide you to structure your code. However, when it comes to system architecture, Object-Oriented Programming is the clear tool for the job.
Not only does Object-Oriented Programming (OOP) enable us to create a flexible plugin architecture and build modularity into our projects, but it also provides the 4 core principles of OOP (Encapsulation, Abstraction, Inheritance, and Polymorphism) that help us create rich, testable domain models.
[!TIP] Deepen your understanding of OOP in practice by exploring the Short & Crispy Python OOPs Tags .
1. Paradigms & The Architect’s Tool
Understanding the structural boundaries of software begins with identifying the building blocks of object modeling:
- Nouns (Classes & Objects): Represent the state, data structures, and entities within the domain.
- Verbs (Behavior & Methods): Represent the operations, mutations, and actions executed by these entities.
2. Classes and Objects
To learn how to approach object modeling as a beginner, explore these introductory walkthroughs:
🎥 LLD for Beginners: Object Modeling Basics
🎥 Class Structure & Implementation
3. Class Relationships
In Low-Level Design (LLD), classes relate to one another in two fundamental ways:
3.1 The “HAS-A” Relationship (Association)
This represents structural association, which is further split into two distinct strengths of lifecycle dependency:
- Composition (Strong Dependency):
- The child object cannot exist independently of the parent object.
- Example: A Customer
has-aCredit Card. If the Customer profile is deleted, there isno logical existence of that credit cardwithin the system.
- Aggregation (Weak Dependency):
- The child object can exist independently of the parent container.
- Example: A Cart
has-aProduct. If the Cart is emptied or deleted, the Productcontinues to existin the inventory catalog.
3.2 The “IS-A” Relationship (Generalization)
This represents subclassing and generalization through inheritance:
- It establishes a
strict taxonomic inheritance relationwhere the subclass inherits state and behavior from the superclass. - Examples:
- ParkingLesson
is aCarLesson. - DrivingLesson
is aCarLesson.
- ParkingLesson
4. Inheritance and Polymorphism
Mastering how base classes dynamic-dispatch subclass logic is central to designing extensible software boundaries: