정리한 내용 중 잘못된 내용이 있을 수 있습니다. 잘못된 내용이 있다면 꼭 알려주세요.
public void horriblyFormattedMethod() {
System.out.println("First line");
System.out.println("Second line");
System.out.println("Third line");
for (int i = 0; i < 3; i++)
System.out.println("number " + i);
}
위 코드를 보면 포맷팅을 보면 혼란스럽다🤔
public void horriblyFormattedMethod() {
System.out.println("First line");
System.out.println("Second line");
System.out.println("Third line");
for (int i = 0; i < 3; i++) {
System.out.println("number " + i);
}
}
아래 처럼 바꾼다면 훨씬 이해하기가 쉽다.
코드의 포맷팅은 가독성에 필수적이다.
~200lines
<500lines
밀접한 개념은 서로 가까이 둔다
1.static 변수 (public -> protected -> package -> private 순서)
2.instance 변수 (public -> protected -> package -> private 순서)
3.생성자
4.메서드
public 메서드에서 호출되는 private 메서드는 그 아래에 둔다. 가독성 위주로 그룹핑
/*
* @(#)Blah.java 1.82 99/03/18
*
* Copyright (c) 1994-1999 Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
* All rights reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*/
package java.blah;
import java.blah.blahdy.BlahBlah;
/**
*
Class description goes here.
*
* @version
1.82 18 Mar 1999 * @author
Firstname Lastname */
public class Blah extends SomeClass {
/* A class implementation comment can go here. */
/**
classVar1 documentation comment */
public static int classVar1;
/**
*
classVar2 documentation comment that happens to be *
more than one line long */
private static Object classVar2;
/**
instanceVar1 documentation comment */
public Object instanceVar1;
/**
instanceVar2 documentation comment */
protected int instanceVar2;
/**
instanceVar3 documentation comment */
private Object[] instanceVar3;
/**
* ...
constructor Blah documentation comment... */
public Blah() {
// ...implementation goes here... }
/**
* ...
method doSomething documentation comment... */
public void doSomething() {
// ...implementation goes here... }
/**
* ...method doSomethingElse
documentation comment... * @param someParam
description */
public void doSomethingElse(Object someParam) {
// ...implementation goes here... }
}
개발 언어의 컨벤션이 우선이지만, 애매한 부분은 팀 컨벤션을 따른다.
없다면, 함께 만들어 가는 것도 좋아요!
MySQL Convention
컬럼명은 snake_case로 네이밍한다.
Team Convention
enum 타입으로 사용하는 varchar 타입의 경우 컬럼명은 _type으로 끝나도록 네이밍한다.