-
Notifications
You must be signed in to change notification settings - Fork 5
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
타입으로 견고하게 다형성으로 유연하게 4주차 - 김영명 #477
base: main
Are you sure you want to change the base?
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.
👍
## 4장 - 두 다형성의 만남 | ||
--- | ||
## [논의 내용] | ||
* 실제 개발에 있어서 어떤 상황에서 공변, 반공변, 불변을 선택해야할까요? 이에 대한 고민을 했었던 사례도 있으셨다면 함께 공유해보면 좋을 것 같습니다! |
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.
사실 저는 딱히 고민하진 않고 개발했던 것 같습니다.
제네릭 타입이면 인터페이스 타입으로 바꾸는 건 아주 많이 하지만
제네릭 T 타입까지 공변을 생각해서 하진 않았던 것 같아요.
제 개인적인 의견으로 공변, 반공변 이런 용어와 사례는
어떻게 보면 이론적인 개념들이고 실제로 정의해서 쓸 때 개념이해 정도로 필요할 것 같긴 하지만
모르고 있다고 해도 구현하는 데 크게 방해될 것 같진 않다고 봅니다.
그래도 알고 있으면 구현한 이유에 대해 설명할 때 더 추상적으로 설명이 가능할 것 같다는 장점이 있을 것 같습니다.
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.
저도 경험해본적은 없었습니다 종필님 말씀대로, 직접적으로 코드에 적용하고 안하고 보다는 개념을 알고 있음으로써, 설계를 할 때나 구현 이유를 설명할 때, 보충의 용도로 충분히 활용할 수 있을거 같습니다
타입으로 견고하게 다형성으로 유연하게 4주차 - Chapter 4
Java에서는 공변과 반변이라고 할 수 있는
<? extends T>
,<? super T>
를 간혹 본 적이 있지만, 이번 챕터를 통해 해당 개념을 더 정리해 볼 수 있는 시간이었던 것 같습니다!책대로
? extends
와? super
를 각각 out과 in으로 바라보니 그나마 이해하기 조금 더 수월했습니다.