(SOLID 원칙 :객체지향 소프트웨어 설계의 근본 원칙, 디자인 패턴의 근본 원칙 객체지향 소프트웨어 설계 도구들의 근본이자 목적이 되는 원칙) A. High-level modules should not depend on low-level modules. Both should depend on abstractions. B. Abstractions should not depend on details. Details should depend on abstractions. - Wikipedia ※ 모든 Parameter 가 Dependency는 아니다.
should depend on abstractions. B. Abstractions should not depend on details. Details should depend on abstractions. SOLID 원칙중 D (Dependency Inversion Principle) public class CoffeeMachine { private ICoffeBean bean; public CoffeMachine(ICoffeBean bean){ this.bean = bean; } public Interface ICoffeeBean { void getBirthYear(); void getHarvestYear(); }
- 생성자에서 DI를 하면 Compile 타임에 보장은 되지만 생성자 Parameter 가 너 무 많아져서 문제.. - setter DI 를 하기엔 각각 setter 를 모두 만들어줘야하고 dependency가 올바로 들어온다는 보장은 없고… - 매번 의존관계 (ex new Something()) 을 생성하는것도 귀찮고...
가능해 진다. public class AlramPresenter { public Boolean isAlramTime(){ Date date = new 시스템시간(); if(date < 수요일){ return true; } else if(date > 수요일){ return false; } } } public class AlramPresenterTest { private AlramPresenter presenter; @Before public void setUp(){ presenter = new AlramPresenter(); } @Test public void before_수요일_Test(){ Boolean result = presenter.isAlramTime(); } @Test public void after_수요일_Test(){ }
있는가? (Component 는 class 에 Module 은 Provides 에 붙이던데..) - Activity Scope이라고 명명하지만 사실 Component 호출 시점이 중요한것이 아 닌가..? Component 에 Activity Scope 이라고 적어놓고 Fragment 에서 생성하 면 결국 생성은 Fragment 에서 한것이니 Fragment 생명주기를 따르지 않을 까..? - @Retention 은 무엇인가?