Dependency injection (DI) je obrazac gdje objekti primaju svoje ovisnosti izvana umjesto da ih sami kreiraju — poboljšavajući testabilnost, održivost i fleksibilnost. U Androidu, Hilt (izgrađen na Daggeru) je preporučeni DI okvir.
Što je DI i zašto
WITHOUT DI: a class CREATES its own dependencies (tightly coupled, hard to test/change):
class UserRepo { val api = ApiService() } // creates its own dependency — rigid
WITH DI: dependencies are PROVIDED from outside (injected):
class UserRepo(val api: ApiService) // receives it → flexible, testable
→ Benefits: TESTABILITY (inject mocks/fakes in tests), DECOUPLING, easier to swap
implementations, centralized dependency management, less boilerplate (with a framework).
