Á¶°ÇÀ» ¹ÝÀü½ÃŰ°í ¸®ÅÏ ¸í·É¹®À» Ãß°¡ÇϽʽÿÀ.
´ÙÀ½ ¼Ö·ç¼Ç¿¡ ´ëÇØ¼´Â Refactoring(Martin Fowler)¿¡¼ ¼³¸íÇϰí ÀÖ½À´Ï´Ù.
- °¡Àå ¹Ù±ù¿¡ ÀÖ´Â if¹®ÀÇ Á¶°ÇÀ» ¹ÝÀü½ÃŰ½Ê½Ã¿À.
- ¸®ÅÏ ¸í·É¹®À» if¹® ¾Æ·¡ Ãß°¡ÇϽʽÿÀ.
- ´õ ÁßøµÈ if¹®ÀÌ ¾øÀ» ¶§±îÁö ÀÌ ´Ü°è¸¦ ¹Ýº¹ÇϽʽÿÀ.
public static void main( String[] args) {
if ( args.length <= 3 ) {
return ;
}
System.out.println( "More than 3" );
if ( !args[ 0 ].startsWith( "a" ) ) {
return ;
}
System.out.println( "Starts with a" );
if ( args[ 1 ].endsWith( "z" ) ) {
System.out.println( "Ends with z" );
}
}
|
|