1. Software Development for Large
and Open Source Projects
Kun-Ta Chuang
Department of Computer Science and Information Engineering
National Cheng Kung University
1
2. Introduction to Java Coding Style
Kun-Ta Chuang
Department of Computer Science and Information Engineering
National Cheng Kung University
2
3. • What is Coding Style?
• Why we need to follow coding standard?
• Java coding standard
3
8. 實作註解
區塊註解(多行註解)
區塊註解可以用在檔案標頭、每個函式之前、或程式碼中的任
何地方。區塊註解的前面應該要有一列空白
/*
Description
不要用很多 * 把註解框起來,像下
面這樣:
A briefde scription of the class/interface.
/*********************
History
* *
yyyy-mm-dd Author
* 這是個錯誤示範 *
What has been changed.
* *
Copyright notice
*********************/
*/
單行註解
// Do a double-flip. In general, 前面要空一行
8
9. 文件註解
• /**
• * Disposes of this graphics context once it is no longer
• * referenced.
• *
• * @see #dispose()
• * @since 1.0
• */
• public void finalize() { dispose(); }
9
28. Why Design Patterns
• 基本上,Pattern 就是一種公式化的表現
– 究竟公式化是不是好事?
– 以藝術來說,公式化的結果會造成僵化
• Pattern is not good
• But for engineering, patterns is good
• Some Patterns are 千錘百鍊
– 運用這些公式可以確保工程具備一定的品質,並
加快工程的進行
– 軟體開發是一項工程
28
29. • Object-Oriented Analysis
• Object-Oriented Programming
• Object-Oriented Design
– We use Design Patterns in OOD
– 對於後續的 OOP、測試、維護,都會有很大的
幫助
• 站在巨人的肩膀
29
31. Simple Factory
• 程式範例 :
public class ClothFactory {
public static Cloth getCloth() { //generate and get a cloth
Cloth cloth = new Cloth();
//do something
return cloth;
}
public static Pant getPant() { //generate and get a pant
Pant pant = new Pant();
//do something
return pant;
}
}
public static void main(String args[]) { //main program
/**only one line, user can get object they want**/
Cloth myCloth = ClothFactory.getCloth();
} 31