🔖 오늘 읽은 범위 : 7장, 오류 처리 (p.130 ~p.142)
😃 책에서 기억하고 싶은 내용을 써보세요.
오류를 정의할 때 프로그래머에게 가장 중요한 관심사는 오류를 잡아내는 방법이 되어야 한다.
호출하는 라이브러리 API를 감싸면서 예외 유형 하나를 반환하면 된다.
LocalPort port = new LocalPort(12);
try {
port.open();
} catch (PortDeviceFailure e) {
reportError(e);
logger.log(e.getMessage(), e);
} finally {
...
}
// LocalPort 클래스처럼 ACMEPort를 감싸는 클래스는 매우 유용하다.
public class **LocalPort** {
private ACMEPort innerPort;
public LocalPort(int portNumber) {
innerPort = new ACMEPort(portNumber);
}
public void open() {
try {
innerPort.open();
} catch (DeviceResponseException | ATM1212UnlockedException | GMXError e) {
**throw new PortDeviceFailure(e);**
}
}
...
}
🤔 오늘 읽은 소감은? 떠오르는 생각을 가볍게 적어보세요
🔎 궁금한 내용이 있거나, 잘 이해되지 않는 내용이 있다면 적어보세요.
I call it my billion-dollar mistake. It was the invention of the null reference in 1965. At that time, I was designing the first comprehensive type system for references in an object oriented language (ALGOL W). My goal was to ensure that all use of references should be absolutely safe, with checking performed automatically by the compiler. But I couldn't resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years.[27]
소감 3줄 요약