Pogrupuj pokrewne klauzule w metody.
- Zidentyfikuj pokrewne klauzule.
- Przenieś pokrewne klauzule tak, aby znajdowały się obok siebie.
- Utwórz metodę o opisowej nazwie dla każdej grupy klauzul.
- Powtarzaj powyższe kroki do momentu, gdy nie będzie już pokrewnych klauzul.
public static void main( String[] args ) {
if ( hasFirstArgument( args ) &&
isValidArgument( args[ 0 ] ) ) {
System.out.println( "Niepoprawny 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" );
}
|
|