티스토리 뷰
리팩토링 검출 메시지
"Reorder the modifiers to comply with the Java Language Specification."
Java class, method 선언 시 표현 순서
2. 접근자 (public/protected/private)
3. abstract
4. static
5. final
6. transient
7. volatile
8. default
9. synchronized
10. native
11. strictfp
잘못된 예 :
public synchronized static String replace(
...
}
변경 :
public static synchronized String replace(
...
}
참고 및 발췌
8.1. Class Declarations
A class declaration specifies a new named reference type.
There are two kinds of class declarations: normal class declarations and enum declarations.
The rules in this section apply to all class declarations, including enum declarations. However, special rules apply to enum declarations with regard to class modifiers, inner classes, and superclasses; these rules are stated in §8.9.
The Identifier in a class declaration specifies the name of the class.
It is a compile-time error if a class has the same simple name as any of its enclosing classes or interfaces.
The scope and shadowing of a class declaration is specified in §6.3 and §6.4.
A class declaration may include class modifiers.
The rules for annotation modifiers on a class declaration are specified in §9.7.4 and §9.7.5.
The access modifier public
(§6.6) pertains only to top level classes (§7.6) and member classes (§8.5), not to local classes (§14.3) or anonymous classes (§15.9.5).
The access modifiers protected
and private
pertain only to member classes within a directly enclosing class declaration (§8.5).
The modifier static
pertains only to member classes (§8.5.1), not to top level or local or anonymous classes.
It is a compile-time error if the same keyword appears more than once as a modifier for a class declaration.
If two or more (distinct) class modifiers appear in a class declaration, then it is customary, though not required, that they appear in the order consistent with that shown above in the production for ClassModifier.
출처 : https://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.1.1
3.1.3 Class and Interface Declarations
The following table describes the parts of a class or interface declaration, in the order that they should appear. See "Java Source File Example" on page 19 for an example that includes comments.
Part of Class/Interface Declaration | Notes | |
---|---|---|
See "Documentation Comments" on page 9 for information on what should be in this comment. | ||
Class/interface implementation comment ( | This comment should contain any class-wide or interface-wide information that wasn't appropriate for the class/interface documentation comment. | |
First the | ||
First | ||
These methods should be grouped by functionality rather than by scope or accessibility. For example, a private class method can be in between two public instance methods. The goal is to make reading and understanding the code easier. |
출처 : https://www.oracle.com/technetwork/java/javase/documentation/codeconventions-141855.html#1852
'리팩토링(스프링기반)' 카테고리의 다른 글
오브젝트 복제하기 (0) | 2019.01.07 |
---|---|
타입선언은 인터페이스로 하자 (0) | 2019.01.07 |
로그인 프로세스 개선 (0) | 2019.01.03 |
조건문 개선 - 중첩된 조건문 처리 하기 (2) | 2019.01.03 |
Use try-with-resources or close this "BufferedInputStream" in a "finally" clause (0) | 2019.01.02 |
- Total
- Today
- Yesterday
- 엑셀
- thymeleaf
- REST
- oracle
- SHEETJS
- restful서비스
- cache
- mapToList
- AG-GRID
- lombok
- Javascript
- 스프링
- 타임리프
- listToMap
- Spring Boot
- 메시지
- example
- java
- 그리드
- sample
- 스프링부트
- 샘플
- 예제
- 설정
- ag grid
- springboot
- mybatis
- spring
- UI
- RESTful
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |