관련 절을 메소드로 그룹화하십시오.
- 관련 절을 식별하십시오.
- 서로 인접한 관련 절을 이동하십시오.
- 각 절 그룹을 설명하는 이름이 있는 메소드를 작성하십시오.
- 관련 절을 모두 사용할 때까지 이러한 단계를 반복하십시오.
public static void main( String[] args ) {
if ( hasFirstArgument( args ) &&
isValidArgument( args[ 0 ] ) ) {
System.out.println( "Not valid argument" );
}
}
private static boolean hasFirstArgument( String[] args ) {
return ( args.length > 0 ) && ( args[ 0 ] != null );
}
private static boolean isValidArgument( String s ) {
return s.equals( "input" ) ||
s.equals( "output" ) ||
s.equals( "verbose" );
}
|
|