[android] Dagger2 Tutorial 1. Dependency Injection 이란? 1.1. Dependency Injection 이 뭐냐? - 어떤 프로그래밍 언어에든 적용할 수 있는 컨셉이다. 이는 Inversion of Control (control 의 역전)이라고도 불린다. 이 컨셉에 따르면 class 는 dependency 를 정적으로 자신이 결정하는 것이 아니라, 바깥쪽에서 dependency 를 결정해주는 방식이다. - public class MyClass{ private final static Logger logger; public MyClass(Logger logger){ this.logger = logger; logger.info(“This is a log message.”); } } 위 코드의 경우 MyClass 가 .. 2018. 12. 4. [android] Dagger2 for Android Beginners - Dagger 는 static, compile-time dependency injection framework 이다. 기존 버전(1.x)은 Square 에 의해 만들어졌고, 새 버전은 (2.x) Google 에 의해 유지보수되고 있다. - Hard dependency 는.. reusability 를 감소시킨다. testing 을 어렵게 한다. 코드의 scale up 이나 유지보수를 어렵게 한다. - Dependency 에는 다음의 type 이 있다. class, interface ,method/field, direct/indirect - java 에서 new operator 로 instance 를 생성하면, 독립적으로 test 되기가 어렵다. 이를 dependency 라 불린다. - Dependency.. 2018. 12. 3. 반응형 이전 1 다음