- 주석은 모든 코드에 상세히 기술하는 것을 원칙으로 한다.
- 소스 코드는 불가피한 내용을 제외하고 원칙적으로 중복을 금지한다. (50 line 소스 중복 코드 금지)
- 소스 코드에서 사용하는 모든 단어는 용어사전의 내용을 기준으로 한다.
- 개발 및 테스트를 수행함에 있어 기능과 성능은 물론 보안에도 각별한 주의를 기울인다.
- File Encoding은 UTF-8을 기본으로 한다. 단, File의 크기가 특정 크기 이상으로 되는 경우 jsp가 정상적으로 동작하지 않는 등의 경우에 대해서는 예외적으로 euc-kr을 사용한다.
1. Package Statements
2. Import Statements
- 사용되는 모든 클래스의 package 명을 기술 (* 사용금지)
3. Class/ Interface Comments (JavaDoc)
4. Class/ Interface Declaration
5. Class/ Interface Comments (Logic) : 선택사항
6. Class Variables Comments (JavaDoc)
7. Class Variables
- 상수 선언 (public -> protected -> default -> private)
- static 변수 선언 (public -> protected -> default -> private
- non-static 변수 선언 (public -> protected -> default -> private)
8. Constructors & Methods Comments (JavaDoc)
9. Constructors & Methods
| 예 | 규칙 |
|---|---|
String▨name▨=▨""; int▨age▨=▨23; |
type과 identifier 사이는 스페이스 1칸으로 설정 |
| int age, nai = 23; | 한 line에 2개 이상의 선언은 피함 |
| int age, nai[] = 23; | 동일한 line에 다른 type들을 두지 않음 |
| 예 | 규칙 |
|---|---|
List list = new LinkedList(); List list = getList(); |
지역 변수는 선언된 곳에서 초기화를 기본으로 함, 할당 연산자의 왼편에만 오는 경우는 상관 없음 |
| 예 | 규칙 |
|---|---|
public void doMethod() throws Exception {
int int1 = 0; // beginning of method block
...
if (condition) {
int int2 = 0; // beginning of if block
...
}
}
|
|
| 예 | 규칙 |
|---|---|
public▨class▨PooImpl▨extends▨Object▨{
}
public▨class▨PooImpl▨implements▨Poo▨{
}
public▨interface▨Poo▨{
}
|
|
public class Poo {
/** POO_VAR : */
private static final String POO_VAR = "var";
/** staticVar : */
public static String staticVar = "";
/**
* Poo Constructor
*/
public Poo() {}
/**
* doSomething method
* @param name
*/
public void doSomething(String name) {
Date date = new Date();
}
}
|
|
| 예 | 규칙 |
|---|---|
String▨name▨=▨""; age++; |
한 line에 한 문장만 포함 |
- ‘{ statements }’와 같이 중괄호를 이용하여 여러 개의 문장을 포함하고 있는 문장을 말한다.
| 예 | 규칙 |
|---|---|
if (condition1) {
▨▨▨▨if (condition2) {
▨▨▨▨▨▨▨▨// Statements
▨▨▨▨}
}
|
|
if (condition) {
age++;
}
|
|
| 예 | 규칙 |
|---|---|
import com.vinylc.ClassName1; import com.vinylc.ClassName2; |
|
| 예 | 규칙 |
|---|---|
return; return▨list.size(); return▨((age▨>▨0)▨?▨age▨:▨0); |
|
| 예 | 규칙 |
|---|---|
if (condition1) {
▨▨▨▨// Statements
}
if▨(condition1)▨{
▨▨▨▨// Statements
}▨else▨(condition2)▨{
▨▨▨▨// Statements
}
if▨(condition1)▨{
▨▨▨▨// Statements
}▨else▨if▨(condition2)▨{
▨▨▨▨// Statements
}▨else▨{
▨▨▨▨// Statements
}
|
|
| 예 | 규칙 |
|---|---|
for▨(initialization;▨condition;▨update)▨{
// Statements
}
|
|
| 예 | 규칙 |
|---|---|
while▨(condition)▨{
▨▨▨▨// Statements
}
|
|
| 예 | 규칙 |
|---|---|
do▨{
▨▨▨▨// Statements
}▨while▨(condition);
|
|
| 예 | 규칙 |
|---|---|
switch▨(key)▨{
▨▨▨▨case▨value1:
▨▨▨▨▨▨▨▨// Statements
▨▨▨▨▨▨▨▨break;
▨
▨▨▨▨case value2:
▨▨▨▨▨▨▨▨// Statements
▨▨▨▨▨▨▨▨break;
▨
▨▨▨▨default:
▨▨▨▨▨▨▨▨// Statements
▨▨▨▨▨▨▨▨break;
}
|
|
| 예 | 규칙 |
|---|---|
try▨{
▨▨▨▨// Statements
}▨catch▨(Exception e) {
▨▨▨▨// Statements
}▨finally▨{
▨▨▨▨// Statements
}
|
|
| 예 | 규칙 |
|---|---|
var▨age▨=▨0; |
|
var age, nai = 0; |
|
var age, nai[] = 23; |
|
| 예 | 규칙 |
|---|---|
var▨age▨=▨0; |
|
var result;
function sumAge(age1, age2) {
// Statements
result = (age1 + age2);
// Statements
}
|
|
| 예 | 규칙 |
|---|---|
function doFunction() {
var int1 = 0; // beginning of function block
...
if (condition) {
var int2 = 0; // beginning of if block
...
}
}
|
|
| 예 | 규칙 |
|---|---|
function▨doFunction()▨{
// Statements
}
|
|
function▨doFunction()▨{}
|
|
| 예 | 규칙 |
|---|---|
var age = 0; age++; |
|
- ‘{ statements }’와 같이 중괄호를 이용하여 여러 개의 문장을 포함하고 있는 문장을 말합니다
| 예 | 규칙 |
|---|---|
if (condition1) {
▨▨▨▨if (condition2) {
▨▨▨▨▨▨▨▨// Statements
▨▨▨▨}
}
|
|
if (condition) {
age++;
}
|
|
| 예 | 규칙 |
|---|---|
return; return true; return (size ? size : defualtsize); |
|
| 예 | 규칙 |
|---|---|
if (condition1) {
▨▨▨▨// Statements
}
if▨(condition1)▨{
▨▨▨▨// Statements
}▨else▨(condition2)▨{
▨▨▨▨// Statements
}
if▨(condition1)▨{
▨▨▨▨// Statements
}▨else▨if▨(condition2)▨{
▨▨▨▨// Statements
}▨else▨{
▨▨▨▨// Statements
}
|
|
| 예 | 규칙 |
|---|---|
for▨(initialization;▨condition;▨update)▨{
// Statements
}
|
|
| 예 | 규칙 |
|---|---|
for (iterable_element▨in▨iterable) {
}
|
|
| 예 | 규칙 |
|---|---|
while▨(condition)▨{
▨▨▨▨// Statements
}
|
|
| 예 | 규칙 |
|---|---|
do▨{
▨▨▨▨// Statements
}▨while▨(condition);
|
|
| 예 | 규칙 |
|---|---|
switch▨(key)▨{
▨▨▨▨case▨value1:
▨▨▨▨▨▨▨▨// Statements
▨▨▨▨▨▨▨▨break;
▨
▨▨▨▨case value2:
▨▨▨▨▨▨▨▨// Statements
▨▨▨▨▨▨▨▨break;
▨
▨▨▨▨default:
▨▨▨▨▨▨▨▨// Statements
▨▨▨▨▨▨▨▨break;
}
|
|
| 예 | 규칙 |
|---|---|
try▨{
▨▨▨▨// Statements
}▨catch▨(e) {
▨▨▨▨// Statements
}
|
|
- jsp 내에서 jsp include는 원칙적으로 사용하지 않는다.
단, 공통 jsp파일(예, top, bottom 등)을 include 하는 경우에는
허용한다.
- 다른 jsp에서 include하는 jsp는 공통 jsp(단위시스템 공통 com경로에 있는jsp)로 한정한다.
- 기본 스크립트 사용을 지양하며, JSTL tag library를 사용하도록 한다.
- 스타일은 css를 사용한다.
- 폼을 서버로 전송할 경우 get방식은 사용하지 않고, post방식을 사용한다.
- 해당 jsp file에서만 사용하는 java script를 제외하고는 java script 소스를 jsp에 작성하지 않는다. (별도의 js파일에 java script를 작성하여 다른 jsp file과 공유하여 소스 중복을 최소화 하기 위함)
- 웹화면은 웹표준 및 접근성 지침을 준수하도록 한다.)
- SELECT, FROM, WHERE, AND, OR, NOW, NULL 등 키워드, 함수등은 대문자로 통일한다.
- 테이블 명이나 컬럼명 등은 소문자로 통일한다.
- WHERE절의 AND는 줄바꿈 처리한다.
- 필드는 하나씩 줄바꿈 처리하며 콤마 띄어쓰기로 사용한다.
| 예 | 규칙 |
|---|---|
SELECT /*▨ProgramID=selectSample▨*/ ▨▨▨▨idx ▨▨▨▨,▨user_id ▨▨▨▨,▨pwd FROM ▨▨▨▨member WHERE ▨▨▨▨user_id=’haha23h’ ▨▨▨▨AND idx=’18’ |
|
INSERT /*▨ProgramID=insertSample▨*/
INTO
▨▨▨▨member▨(
▨▨▨▨▨▨▨▨idx
▨▨▨▨▨▨▨▨,▨user_id
▨▨▨▨▨▨▨▨,▨pwd
▨▨▨▨)
VALUES(
▨▨▨▨▨▨▨▨#{idx}#
▨▨▨▨▨▨▨▨,▨#{user_id}#
▨▨▨▨▨▨▨▨,▨#{pwd}#
)
|
|