| File | Description | Status |
|---|---|---|
| Basic | OOP Fundamentals | ✅ Done |
class BankAccount {
#balance = 0; // Private field
deposit(amount) {
this.#balance += amount;
}
getBalance() {
return this.#balance;
}
}
// Hide complex implementation
class EmailService {
send(to, subject, body) {
// Complex SMTP logic hidden
this.#connect();
this.#authenticate();
this.#sendEmail(to, subject, body);
}
}
class Animal {
speak() { console.log("Sound"); }
}
class Dog extends Animal {
speak() { console.log("Bark!"); }
}
class Shape {
area() { throw "Override this"; }
}
class Circle extends Shape {
constructor(r) { this.r = r; }
area() { return Math.PI * this.r ** 2; }
}
class Rectangle extends Shape {
constructor(w, h) { this.w = w; this.h = h; }
area() { return this.w * this.h; }
}
| Principle | Description |
|---|---|
| S - Single Responsibility | One class = One job |
| O - Open/Closed | Open for extension, closed for modification |
| L - Liskov Substitution | Subclass should be substitutable for parent |
| I - Interface Segregation | Many specific interfaces > One general |
| D - Dependency Inversion | Depend on abstractions, not concretions |
Last Updated: March 2026