Dependency injection (DI) yaiku pola ngendi obyek nampa dependencies saka njaba (injected) tinimbang nggawe dheweke dhewe. Iki ndhukunga loose coupling, testability, lan flexibility — pola fundamental, kang akeh digunakake ing software modern.
Apa sing dimaksud karo dependency injection
WITHOUT DI → a class CREATES its own dependencies (tightly coupled):
class OrderService { constructor() { this.db = new Database(); } } // hardcoded dependency
WITH DI → dependencies are PROVIDED (injected) from outside:
class OrderService { constructor(db) { this.db = db; } } // db is injected
→ the object doesn't create/control its dependencies → they're given to it
