-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[부나] 1단계 자동 DI 미션 제출합니다 #2
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
안녕하세요 부나!
DSL로 깔끔하게 구현한 자동 DI가 인상적이었습니다!
변경 요청보단 궁금한 점 위주로 리뷰하였습니다.
확인 부탁드리겠습니다.!!
class ClassInjectorDsl { | ||
inline fun <reified T : Any> inject(instance: T) { | ||
ClassInjector.inject(instance) | ||
} | ||
} | ||
|
||
fun modules(block: ClassInjectorDsl.() -> Unit) { | ||
ClassInjectorDsl().apply(block) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DI 라이브러리를 구현하는 입장에서 DSL로 구현하신점 멋지네요.
DSL로 구현하시면서 체감되는 장점은 어떤 것들이 있었나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DSL의 장점은 아무래도 조금 더 코틀린스럽게 코드를 작성할 수 있는 것이 가장 큰 장점이라고 생각합니다.
이번 미션은 마치 라이브러리를 만드는 느낌이 강했기 때문에,
본인을 포함하여, 코드를 사용하는 개발자 입장에서 생각해봤을 때
보다 깔끔하고 편리하게 코드를 사용할 수 있을 것이라고 생각합니다.
@MainThread | ||
inline fun <reified VM : ViewModel> ComponentActivity.viewModel(): Lazy<VM> { | ||
return ViewModelLazy( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MainThread
어노테이션 사용 이유가 궁금합니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
기존 코드에서는 내부적으로 MainThread에서 동작하는 함수가 일부 있어서 추가해두었습니다.
지금은 필요 없으니 제거해도 괜찮아 보이네요! 👍🏻
class CartViewModel constructor( | ||
private val cartRepository: CartRepository, | ||
) : ViewModel() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constructor
를 명시해준 이유가 궁금합니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
원래는 constructor와 관련된 애노테이션을 사용할 것을 가정하고 constructor
를 명시해주었습니다.
하지만 미션 요구사항과 같이 애노테이션을 사용하지 않는 것을 원칙으로 하고 있기 때문에 명시해줄 필요가 없어보이네요!
제거하도록 하겠습니다 : )
@OptIn(ExperimentalStdlibApi::class) | ||
fun getParameterValues(parameters: List<KParameter>): MutableList<Any> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OptIn
어노테이션을 사용하신 이유가 궁금합니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아 request changes를 안해서 리뷰반영 요청이 안들어가네요 한번 더 작성하겠습니다. 죄송합니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1단계 미션 고생 많으셨습니다!
역쉬 고수부나군요.
어노테이션 사용시 어떻게 바뀔지 기대가 됩니다!
안녕하세요 반달!
지연/리플렉션을 통해 구현하였습니다.
코드를 보다가 의구심이 드는 부분은 과감하게 리뷰해주세요!
테스트 코드는 정상적으로 통과하며, 요구사항 체크리스트는 아래와 같이 완료하였습니다.
감사합니다.
+) 따로 Dao를 사용하지 않았기 때문에 Repository 단위 테스트는 진행하지 않았습니다.
이후에 Room을 사용하면 테스트 코드를 추가로 작성하겠습니다 : )
0.5단계
기능 요구 사항
생성자 주입 - 수동
다음 문제점을 해결한다.
1단계
기능 요구 사항
생성자 주입 - 자동
다음 문제점을 해결한다.
선택 요구 사항
프로그래밍 요구 사항