Skip to Content
자바에서 코틀린으로
book

자바에서 코틀린으로

by 덩컨 맥그레거, 냇 프라이스, 오현석
November 2022
Beginner to intermediate
544 pages
12h 39m
Korean
Hanbit Media, Inc.
Content preview from 자바에서 코틀린으로
416
자바에서 코틀린으로
19.7.4
밖으로 나가기
Customers
에 적용한 패턴을
IRegisterCustomers
::
register
에도 똑같이 적용하려고 하
면(예외를 던지는 코드와 결과를 반환하는 코드 사이에 어댑터의 디폴트 구현을 추가하려 하
면) 두 가지 이유로 실패할 수 있는 함수의 결과를 어떻게 표현해야 하느냐는 문제를 해결해
야 한다. 그것이 바로
register
ExcludedException
DuplicateException
이라는 두
체크 예외를
throws
절에 선언해둔 이유이다. 코드로 설명하면, 우리는
Result
<
Customer
,
Either
<
ExcludedException
,
DuplicateException
>>
와 비슷한 무언가를 원한다.
일반적인
Either
타입을 사용할 수도 있겠지만, 전략으로 채택하기에는 조금 너무 멀리 나간
감이 있다. 예외를 선언하는 순서가 중요하지 않은 자바와 달리
Either
<
ExcludedException
,
DuplicateException
>
Either
<
DuplicateException
,
ExcludedException
>
같지
않다.
Either
는 기껏해야 혼동이나 야기하고 예외가 셋 이상인 경우에는 문제를 더 악화시키
기까지 한다.
OneOf
<
ExcludedException
,
DuplicateException ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

고성능 파이썬(2판)

고성능 파이썬(2판)

오현석, 미샤 고렐릭, 이안 오스발트
러닝 타입스크립트

러닝 타입스크립트

조시 골드버그
실리콘밸리 리더십

실리콘밸리 리더십

김정혜, 마이클 롭

Publisher Resources

ISBN: 9791169210447