Last active
August 29, 2015 14:25
-
-
Save grimrose/f1064c002aa6bed45536 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 元ネタ | |
if(!((条件A || 条件B || 条件C)&&( 条件D || 条件E)){ | |
// do something | |
} | |
// 自分がリファクタリングするなら | |
if (改善後条件(argument)) { | |
doSomething(argument); | |
} | |
function doSomething(argument) { | |
// do something | |
} | |
function 改善後条件(argument) { | |
if (条件Aor条件Bor条件C(argument) && 条件Dor条件E(argument)) { | |
return false; | |
} | |
return true; | |
} | |
function 条件Aor条件Bor条件C(argument) { | |
if (条件A(argument)) { | |
return true; | |
} | |
if (条件B(argument)) { | |
return true; | |
} | |
if (条件C(argument)) { | |
return true; | |
} | |
return false; | |
} | |
function 条件Dor条件E(argument) { | |
if (条件D(argument)) { | |
return true; | |
} | |
if (条件E(argument)) { | |
return true; | |
} | |
return false; | |
} | |
function 条件A(argument) { | |
// return t or f | |
} | |
function 条件B(argument) { | |
// return t or f | |
} | |
function 条件C(argument) { | |
// return t or f | |
} | |
function 条件D(argument) { | |
// return t or f | |
} | |
function 条件E(argument) { | |
// return t or f | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment