Created
March 14, 2018 16:06
-
-
Save cheese10yun/570edaf1e8bf574c0de7c139da32c39b to your computer and use it in GitHub Desktop.
클린코드 : 오류 코드보다 예외를 사용하라 예제
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//클린 코드 도서 예제 | |
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