2.코드스타일 레벨업
2.1 매직넘버를 상수로 대체
if (speedPreset == 2){
// ..
} else if(speedPreset == 1){
// ..
} else if(speedPreset == 0) {
// ..
}private static final int STOP_PRESET = 0;
private static final int PLANETARY_SPEED_PRESET = 1;
private static final int CRUISE_SPEED_PRESET = 2;2.2 정수 상수 대신 열거형
enum SpeedPreset {
STOP(0), PLANETRAY(1), CRUISE(2);
}2.3 For루프 대신 Foreach
2.4 순회하며 컬렉션 수정하지 않기
Last updated