- naver coding convention
- ./rule ์๋์
naver-checkstyle-rules.xml,naver-intellij-formattter.xmlํ์ผ์ด ์์นํ๋ค.
File->Settings->Editor->Code Style->Javaํญ๋ชฉ์ผ๋ก ์ด๋Scheme๋ฉ๋ด์์Import Scheme->IntelliJ IDEA code style XML์ ์ ํ./rule์๋์ ์์นํnaver-intellij-formattter.xmlํ์ผ์ ์ ํํ ํ ์ ์ฉ
- Null Validation ์ด ํ์ํ ๊ฒฝ์ฐ
@NotNull์ ์ฌ์ฉํด์ validation ์์ ์ ํ๊ฐ์ง๋ก ํต์ผํ๋ค.@javax.validation.NotNull์ Validation ์ด ํ์ํ not-null ์์ฑ์ ๋ถ์ธ๋ค.
@Nullable์ ์ฌ์ฉํ์ฌ null ์ด ๋ ์ ์๋ ๊ฒฝ์ฐ๋ฅผ ๋ช ์์ ์ผ๋ก ํํํด์ค๋ค.- ๋ฉ์๋ ํ๋ผ๋ฏธํฐ์๋
null์ด ๋ ์ ์๋ ํ๋์ ํํด@Nullable์ ์ ์ฉํ ์ ์๋ค.
- ๋ฉ์๋ ํ๋ผ๋ฏธํฐ์๋
- ๊ธฐ๋ณธ์ ์ผ๋ก ๋ฉ์๋์์
null์ ๋ฆฌํดํ์ง ์๋๋ก ํ๋ฉฐ, ๊ฐ๋ฅ์ฑ์ด ์์ ๊ฒฝ์ฐOptional์ ์ฌ์ฉํ๋ค.
- ๊ธฐ๋ณธ์ ์ผ๋ก ๋ก์ง ๋ด์์๋
null๋์empty()๋ฅผ ํ์ฉํ๋ค. - Nullable ์์ฑ์ผ ๊ฒฝ์ฐ ํด๋น ํ๋์
@Nullable์ ๋ช ์ํ๊ณgetter๋ฅผ ๊ตฌํํ์ฌ ๊ณตํต์ ์ผ๋ก Null ์ ๋ฐฉ์งํ๋ค. - ์ธ๋ถ์ (public) List, Set, Map ํ๋๋ฅผ ์ ๊ณตํ๋ค๋ฉด
unmodifiableList๋ฅผ ํ์ฉํ๋ค.
@Getter
public static class Sample {
@Nullable
private List<String> list;
public List<String> getList() {
return isNull(list) ? emptyList() : unmodifiableList(list);
}
public void add(String element) {
if (this.list == null) {
this.list = new ArrayList();
}
this.list.add(element);
}
}Enum ๋ณ์ ์ด๋ฆ๊ณผ ๋ง์ถ์ด Type ์ผ๋ก suffix ๋ฅผ ๋ถ์ธ๋ค.
private MemberType memberType;- static ๋ฉ์๋๋ก ๊ตฌ์ฑ๋ Utility ํด๋์ค์๋ lombok ์
@UtilityClass๋ฅผ ๋ถ์ธ๋ค. - Util ํน์ฑ์ ๋ํ๋ด๋ ์ด๋ฆ์ ๋ณต์ํ์ ์ฌ์ฉํ๋ค. (ex:
PhoneNumbers,Times) - ์์กดํ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๋์ผํ ์ด๋ฆ์ด ์๋ค๋ฉด,
Supports๋ฅผ postfix ๋ก ๋ถ์ธ๋ค. (Collections -> CollectionSupports) com.bluebird.pipit.xxx.supportํจํค์ง ์์์ ์์ฑํ๋ค.
- Constructor : 3๊ฐ ์ดํ์ parameter ๋ก ๊ฐ์ฒด๋ฅผ ์์ฑํ๋ ๊ฒฝ์ฐ
- Builder Pattern : 4๊ฐ ์ด์์ parameter ๋ก ๊ฐ์ฒด๋ฅผ ์์ฑํ๋ ๊ฒฝ์ฐ
- Static Factory Method : ๊ฐ์ฒด ์์ฑ์ ์๋ฏธ ๋ถ์ฌ๊ฐ ํ์ํ ๊ฒฝ์ฐ
