Documentation Index
Fetch the complete documentation index at: https://resources.devweekends.com/llms.txt
Use this file to discover all available pages before exploring further.
🧱 Think of Code Like LEGO
Imagine you’re building with LEGO blocks. Each block is a piece that can connect with other blocks to build something amazing - like a castle, a spaceship, or a city! Object-Oriented Programming (OOP) works the same way:- Instead of LEGO blocks, we have Objects
- Objects are like little machines that can store information and do things
- We connect objects together to build amazing software!
Without OOP
With OOP
🐕 Your First Object: A Dog!
Let’s create a simple object in our minds - a Dog. What does every dog have?- A name (like “Buddy”)
- A color (like “brown”)
- An age (like 3 years)
- Bark (“Woof woof!”)
- Eat (munch munch)
- Sleep (zzz…)
- Things a dog has = Attributes (or Properties)
- Things a dog can do = Methods (or Actions)
The Four Superpowers of OOP
OOP gives you four amazing superpowers (we call them “pillars”):1. Encapsulation
2. Inheritance
3. Polymorphism
4. Abstraction
Why Does Everyone Use OOP?
Almost every app you use is built with OOP:| App | Objects You’d Find Inside |
|---|---|
| Video Games | Player, Enemy, Weapon, Level, Score |
| User, Post, Comment, Like, Story | |
| Amazon | Product, Cart, Order, Customer, Review |
| Spotify | Song, Playlist, Artist, Album, User |
| Uber | Driver, Rider, Trip, Payment, Location |
- Easy to understand - Objects match how we think in real life
- Easy to change - Fix one object without breaking others
- Easy to reuse - Use the same object in different projects
- Easy to team work - Different people work on different objects
Try It Yourself!
Let’s make sure you understand before moving on:Quiz 1: What is a class?
Quiz 1: What is a class?
- A cookie cutter (class) → makes cookies (objects)
- A car factory blueprint (class) → makes actual cars (objects)
- A dog breed description (class) → describes actual dogs (objects)
Quiz 2: What's the difference between attribute and method?
Quiz 2: What's the difference between attribute and method?
-
Attributes = What something HAS (data, properties)
- Example: A car HAS a color, speed, brand
-
Methods = What something CAN DO (actions, behaviors)
- Example: A car CAN start, stop, accelerate
Quiz 3: Identify the objects in a School System
Quiz 3: Identify the objects in a School System
- Student (has: name, age, grade | can: study, take exam, join club)
- Teacher (has: name, subject, salary | can: teach, grade papers, assign homework)
- Classroom (has: room number, capacity | can: host class, be booked)
- Course (has: name, credits | can: enroll student, generate report)
What’s Next?
Now that you understand the basics, let’s dive deep into each superpower:Interview Insight
Interview Deep-Dive
An interviewer says: 'Explain the difference between a class and an object to me as if I am a non-technical stakeholder.' Then they follow up: 'Now explain it at a senior engineer level.'
An interviewer says: 'Explain the difference between a class and an object to me as if I am a non-technical stakeholder.' Then they follow up: 'Now explain it at a senior engineer level.'
- Non-technical explanation: A class is a blueprint, like the architectural plan for a house. An object is an actual house built from that blueprint. You can build many houses from the same plan, but each house has its own address, paint color, and residents. Changing the furniture in one house does not affect the others.
- Senior engineer explanation: A class defines a type — it specifies the memory layout (attributes), the behavioral contract (methods), and the access control (public/private). An object is a runtime instance allocated on the heap with its own state. The class is a compile-time construct; the object is a runtime construct. In Python, classes themselves are also objects (instances of the metaclass
type), which enables metaprogramming patterns like Singleton metaclasses and dynamic class creation. - The practical interview implication: when you identify “a Dog” in a problem statement, you are identifying a class. When you say “Buddy the golden retriever with age 3,” you are identifying an object. The interviewer wants to see that you think about both the type hierarchy (design level) and the runtime instances (implementation level).
Given a problem statement -- 'Design a school management system' -- walk me through exactly how you identify the classes, attributes, and methods from the text.
Given a problem statement -- 'Design a school management system' -- walk me through exactly how you identify the classes, attributes, and methods from the text.
- Step 1: Extract nouns from the requirements. “School management system” gives us: School, Student, Teacher, Course, Classroom, Grade, Schedule, Enrollment. Each noun is a candidate class.
- Step 2: Filter nouns. Some nouns are attributes rather than classes. “Name” is an attribute of Student, not its own class. “Grade” could be a class (if it has behavior) or an enum (if it is just a label). I ask: does this noun have both data AND behavior? If yes, it is a class. If it is just data, it is an attribute.
- Step 3: Extract verbs. “Enroll student in course,” “assign teacher to course,” “generate report card,” “schedule classes.” Each verb becomes a candidate method, and the subject-object relationship tells you which class owns the method. “Enroll student” means Course or EnrollmentService has an enroll(student) method.
- Step 4: Identify relationships. Student enrolls in Course (many-to-many, resolved by an Enrollment class). Teacher teaches Course (one-to-many). Course is held in Classroom (one-to-one per time slot). These relationships become association, composition, or aggregation lines on the class diagram.
- Step 5: Validate with use cases. “A student enrolls in a course” — trace through the classes: Student calls EnrollmentService.enroll(), which checks Course.hasCapacity(), creates an Enrollment object, and notifies the Student. If the trace breaks, the design is missing a class or method.
Why does OOP dominate LLD interviews, and what are its limitations that a senior engineer should acknowledge?
Why does OOP dominate LLD interviews, and what are its limitations that a senior engineer should acknowledge?
- OOP dominates LLD interviews because it provides a shared vocabulary for discussing design. Classes, interfaces, inheritance, and composition map naturally to how interviewers and candidates communicate about system structure. When someone says “Vehicle is an abstract class with Car and Truck subclasses,” everyone pictures the same hierarchy.
- OOP is excellent for modeling entities with state and behavior: a BankAccount that has a balance and can deposit/withdraw, a Game with players and moves, a ParkingLot with floors and spots. It naturally handles the “nouns and verbs” decomposition that LLD problems require.
- However, OOP has real limitations. First, it can lead to over-modeling: creating class hierarchies for things that are better represented as data transformations (functional programming) or simple dictionaries. Not every concept needs a class. Second, deep inheritance hierarchies create fragile coupling. Third, OOP can obscure the flow of data through a system — you have to chase method calls across many classes to understand what happens during a request.
- In practice, the best LLD designs use OOP for entity modeling and structural organization, but borrow from functional programming for stateless transformations (pricing calculations, validation pipelines) and from event-driven architecture for decoupled communication (Observer pattern, message queues).