class ViewController(
private val inputView: InputView,
private val outputView: OutputView
)
Class
는 인스턴스화 하는 class
에 의존한다.
ViewController Class
는 inputView, OutputView class
에 의존한다.class ViewController {
private val inputView = InputView("페토")
private val outputView = OutputView()
}
<aside> 💡
컴포지션에 대해 더 알고싶다면 ? Effective Kotlin Item 35. 상속보다 컴포지션을 사용하라
</aside>
class Student(
val name: String,
val age: Int
// val hoby: String
)
class Inject(val item: Student) { }
class Composition {
val item = Student("페토", 20)
}
class Student(
val name: String,
val age: Int
val hoby: String
)
class Composition {
val items = Student("페토", 99, "축구")
}
CompositionController Class
또한 수정해야 한다.CompositionController Class
가 Student Class
를 인스턴스화 하는 책임을 가지고 있다.Student Class
에 의존<aside> 💡
결합도와 응집도가 왜 중요한지 궁금하다면 ? https://medium.com/@soqlehsoqleh/solid-a3717cb99ae8
</aside>