Skip to content
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

서브타입에 더 강한 사전 조건을 정의하거나 더 약한 사후 조건을 정의하는 경우는 LSP를 위반한다고 볼 수 있을까? #59

Open
kmw2378 opened this issue Feb 22, 2024 · 0 comments
Assignees
Labels
궁금한 내용 및 토론하고 싶은 내용
Milestone

Comments

@kmw2378
Copy link
Collaborator

kmw2378 commented Feb 22, 2024

13장 마지막 부분에 서브타입과 계약과 관련된 내용이 나오는데, 제 생각을 요약하자면 다음과 같습니다.

서브타입에 더 강한 사전 조건을 정의할 수 없다.

  • (더 강한 사전 조건) ⊂ (사전 조건) ⊂ (더 약한 사전 조건) 이므로 사전 조건이 더 강해지면 파라미터 문맥이 제한되므로 사용이 이전과 달라진다 생각합니다.

서브타입에 더 약한 사후 조건을 정의할 수 없다.

  • (더 강한 사후 조건) ⊂ (사후 조건) ⊂ (더 약한 사후 조건) 이므로 사후 조건이 더 약해지면 클라이언트 입장에서 예상치 못한 응답값이 나온다 생각합니다.

궁극적으로 이 둘 중 하나라도 어긴다면 클라이언트 입장에서 서브타입의 사용이 슈퍼타입의 사용과 달라지므로 LSP를 위반한다고 생각합니다! 다른 분들은 어떻게 생각하실까요?

@kmw2378 kmw2378 added the 궁금한 내용 및 토론하고 싶은 내용 label Feb 22, 2024
@kmw2378 kmw2378 added this to the 7주차 milestone Feb 22, 2024
@kmw2378 kmw2378 self-assigned this Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
궁금한 내용 및 토론하고 싶은 내용
Projects
None yet
Development

No branches or pull requests

1 participant