void initialize() {
if (!isInitialized()) {
...
}
}
if (!isInitialized()) {
...
}
}
이 코드가 좋다
void initialize() {
if (isInitialized()) {
return;
}
...
}
if (isInitialized()) {
return;
}
...
}
이 코드를 보면 더 명확하다.
void compute {
Server server = getServer();
if (server != null) {
Client client = server.getClient();
if (client != null) {
Request current = client.getRequest();
if (current != null) {
processRequest(current);
}
}
}
Server server = getServer();
if (server != null) {
Client client = server.getClient();
if (client != null) {
Request current = client.getRequest();
if (current != null) {
processRequest(current);
}
}
}
void compute {
Server server = getServer();
if (server == null)
return;
Client client = server.getClient();
if (client == null)
return;
Request current = client.getRequest();
if (current == null)
return;
processRequest(current);
}
Server server = getServer();
if (server == null)
return;
Client client = server.getClient();
if (client == null)
return;
Request current = client.getRequest();
if (current == null)
return;
processRequest(current);
}
* 켄트 백의 구현 패턴 7장 Behavior에서 발췌
No comments:
Post a Comment