僕のリファクタリング elseをなくすようにする
2006/06/29
2008/03/23

Java言語を使用して、あるメソッドを実装したとする例えば、
void method(){
if(condition){
a();
} else {
b();
}
return;
}
僕ならまずこう変更する。
void method(){
if(condition){
a();
return;
}
b();
}
僕のリファクタリング
(1)
if文のelseをなくすようにする。
(2)
さっさとreturnさせる。
(3)
elseの中でif文をネストさせないようにする。
void method(){
if(condition){
a();
} else {
b();
}
return;
}
僕ならまずこう変更する。
void method(){
if(condition){
a();
return;
}
b();
}
僕のリファクタリング
(1)
if文のelseをなくすようにする。
(2)
さっさとreturnさせる。
(3)
elseの中でif文をネストさせないようにする。
: