규칙 1: 한 메서드에 오직 한 단계의 들여쓰기만 한다.
규칙 2: else 예약어를 쓰지 않는다.
규칙 3: 모든 원시값과 문자열을 포장한다.
규칙 4: 한 줄에 점을 하나만 찍는다.
규칙 5: 줄여쓰지 않는다(축약 금지).
규칙 6: 모든 엔티티를 작게 유지한다.
규칙 7: 2개 이상의 인스턴스 변수를 가진 클래스를 쓰지 않는다.
규칙 8: 일급 콜렉션을 쓴다.
규칙 9: 게터/세터/프로퍼티를 쓰지 않는다.
참고문헌
출처 : https://developerfarm.wordpress.com/2012/02/03/object_calisthenics_summary/
try - with - resources 문법으로 바꿔서 쓰면 close하지 않아도 자동으로 close 해 준다.
/**
* @brief Path argument를 통해 파일에서 토큰을 추출해오는 함수
* @param path token이 들어있는 path 경로
* @return String
*/
public static String ReadToken(String path) throws IOException{
try (
BufferedReader tokenReader = new BufferedReader(new FileReader(path));
) {
String str = null;
String buffer = null;
while ((buffer = tokenReader.readLine()) != null) {
str = buffer;
}
return str;
} catch (FileNotFoundException e) {
System.out.println("Cannot find File");
e.printStackTrace();
throw e;
} catch (IOException e) {
e.printStackTrace();
throw e;
}
}