Skip to content

Instantly share code, notes, and snippets.

@cheese10yun
Created March 14, 2018 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cheese10yun/570edaf1e8bf574c0de7c139da32c39b to your computer and use it in GitHub Desktop.
Save cheese10yun/570edaf1e8bf574c0de7c139da32c39b to your computer and use it in GitHub Desktop.
클린코드 : 오류 코드보다 예외를 사용하라 예제
//클린 코드 도서 예제
public class DeviceController {
...
public void sendShutDown() {
DeviceHandle handle = getHandle(DEV1);
// 디바이스 상태를 점검한댜.
if (handle != DeviceHandle.INVALID) {
// 레코드 필드에 디바이스 상태를 저장한다.
retrieveDeviceRecord(handle);
// 디바이스가 일시정지 상태가 아니라면 종료한다.
if (record.getStatus() != DEVICE_SUSPENDED) {
pauseDevice(handle);
clearDeviceWorkQueue(handle);
closeDevice(handle);
} else {
logger.log("Device suspended. Unable to shut down");
}
} else {
logger.log("Invalid handle for: " + DEV1.toString());
}
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment