コードコアのクリア(5章フォーマット)
フォーマットはなぜ重要ですか? 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);
}
}
今は理解できます!
読み取り可能性が必要です
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);
}
}
クリーンコードの書式設定
適当な長さを保つ
~200 lines < 500 lines
200ライン
->現在、業界のほとんどのコードも200行程度に維持されています.
密接な概念が互いに近づく。
Java Class Declarations
クラス内のコード順序。
せいてきへんすう
public→protected→package→private順
インスタンス変数
public → protected → package → private
生成者
方法
publicメソッドで呼び出されるprivateメソッドは、その下にあります.
可読性をメイングループPing!
例
/*
* @(#)Blah.java 1.82 99/03/18
*
* Copyright (C) 1994-1998 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 {
public static int classVar1;
private static Object classVar2; // static 변수
public Object instanceVar1;
protected int instanceVar2;
private Object[] instanceVar3; // instance 변수
public Blah() { // 생성자
// ...implementation goes here...
}
public void doSomething() { // 메서드
// ...implementation goes here...
}
public void doSomethingElse(Object someParam) {
// ...implementation goes here...
}
}
Team Coding Convention
言語を開発する会議を優先しますが、あいまいな部分はチーム会議に従います.
もしなかったら、一緒に創造してもいいです.
リファレンス
これらの情報はゼロベースラインクリーニングコード毎月1冊を聞いた後に整理された.
Reference
この問題について(コードコアのクリア(5章フォーマット)), 我々は、より多くの情報をここで見つけました
https://velog.io/@coconenne/클린코드-핵심-정리-4장-형식-맞추기
テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol
これらの情報はゼロベースラインクリーニングコード毎月1冊を聞いた後に整理された.
Reference
この問題について(コードコアのクリア(5章フォーマット)), 我々は、より多くの情報をここで見つけました https://velog.io/@coconenne/클린코드-핵심-정리-4장-형식-맞추기テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol