SOLID Principles
SOLID Principles 1. S — Single Responsibility Principle (SRP) 👉 A class should have only one reason to change. Bad Example ❌ class Payment { void makeUPIPayment () { } void generateReceipt () { } void sendNotification () { } } This class does too much → payment + receipt + notification. Good Example class UPIPayment { void makePayment() { } } class ReceiptGenerator { void generateReceipt() { } } class NotificationService { void sendNotification() { } } Each class has one responsibility . If tomorrow notification changes ( SMS → WhatsApp ), only NotificationService changes. 2. O — Open/Closed Principle (OCP) 👉 Classes should be open for extension but closed for modification . Bad Example ❌ class PaymentProcessor { void process(String type) { if(type.equals("UPI")) { /* UPI logic */ } else if(typ...