Practical Java Programming Language Guide
暫譯: 實用 Java 程式語言指南

Peter Haggar

  • 出版商: Addison Wesley
  • 出版日期: 2000-02-11
  • 售價: $1,560
  • 貴賓價: 9.5$1,482
  • 語言: 英文
  • 頁數: 320
  • 裝訂: Paperback
  • ISBN: 0201616467
  • ISBN-13: 9780201616460
  • 相關分類: Java 程式語言
  • 立即出貨 (庫存 < 3)

買這商品的人也買了...

商品描述


Description

This broad-ranging guide can help students with varying levels of expertise to understand Java more completely and to maximize their coding effectiveness. This book's rules-based format examines 68 key topics on how to improve code, providing crisp, well-written examples and solutions. All of the examples and solutions are accompanied by thorough explanations for achieving a working solution. This practical approach to programming and design describes the best practices used by experienced programmers. To access the source code, register the book at the following Web site: http://www.awl.com/cseng/register

Back to Top


Appropriate Courses

Java--Intermediate Programming.

Back to Top


Table Of Contents

Preface.
Acknowledgments.

GENERAL TECHNIQUES.

Praxis 1: Understand that parameters are passed by value, not by reference.
Praxis 2: Use final for constant data and constant object references.
Praxis 3: Understand that all non-static methods can be overridden by default.
Praxis 4: Choose carefully between arrays and Vectors.
Praxis 5: Prefer polymorphism to instance of.
Praxis 6: Use instance of only when you must.
Praxis 7: Set object references to null when they are no longer needed.

OBJECTS AND EQUALITY.

Praxis 8: Differentiate between reference and primitive types.
Praxis 9: Differentiate between == and equals.
Praxis 10: Do not rely on the default implementation of equals.
Praxis 11: Implement the equals method judiciously.
Praxis 12: Prefer get Class in equals method implementations.
Praxis 13: Call super. equals of base classes.
Praxis 14: Consider carefully instance of in equals method implementations.
Praxis 15: Follow these rules when implementing an equals method.

EXCEPTION HANDLING.

Praxis 16: Know the mechanics of exception control flow.
Praxis 17: Never ignore an exception.
Praxis 18: Never hide an exception.
Praxis 19: Consider the drawback to the throws clause.
Praxis 20: Be specific and comprehensive with the throws clause.
Praxis 21: Use finally to avoid resource leaks.
Praxis 22: Do not return from a try block.
Praxis 23: Place try/catch blocks outside of loops.
Praxis 24: Do not use exceptions for control flow.
Praxis 25: Do not use exceptions for every error condition.
Praxis 26: Throw exceptions from constructors.
Praxis 27: Return objects to a valid state before throwing an exception.

PERFORMANCE.

Praxis 28: Focus initially on design, data structures, and algorithms.
Praxis 29: Do not rely on compile-time code optimization.
Praxis 30: Understand runtime code optimization.
Praxis 31: Use String Buffer, rather than String, for concatenation.
Praxis 32: Minimize the cost of object creation.
Praxis 33: Guard against unused objects.
Praxis 34: Minimize synchronization.
Praxis 35: Use stack variables whenever possible.
Praxis 36: Use static, final, and private methods to allow in lining.
Praxis 37: Initialize instance variables only once.
Praxis 38: Use primitive types for faster and smaller code.
Praxis 39: Do not use an Enumeration or an Iterator to traverse a Vector.
Praxis 40: Use System array copy for copying arrays.
Praxis 41: Prefer an array to a Vector or Array List.
Praxis 42: Reuse objects whenever possible.
Praxis 43: Use lazy evaluation.
Praxis 44: Optimize source code by hand.
Praxis 45: Compile to native code.

MULTITHREADING.

Praxis 46: Understand that for instance methods, synchronized locks objects, not methods or code.
Praxis 47: Distinguish between synchronized statics and synchronized instance methods.
Praxis 48: Use private data with an accessor method instead of public or protected data.
Praxis 49: Avoid unnecessary synchronization.
Praxis 50: Use synchronized or volatile when accessing shared variables.
Praxis 51: Lock all objects involved in a single operation.
Praxis 52: Acquire multiple locks in a fixed, global order to avoid deadlock.
Praxis 53: Prefer notify All to notify.
Praxis 54: Use spin locks for wait and notify All.
Praxis 55: Use wait and notify All instead of polling loops.
Praxis 56: Do not reassign the object reference of a locked object.
Praxis 57: Do not invoke the stop or suspend methods.
Praxis 58: Terminate threads through thread cooperation. Classes and Interfaces.
Praxis 59: Use interfaces to support multiple inheritance.
Praxis 60: Avoid method clashes in interfaces.
Praxis 61: Use abstract classes when it makes sense to provide a partial implementation.
Praxis 62: Differentiate between an interface, abstract class, and concrete class.
Praxis 63: Define and implement immutable classes judiciously.
Praxis 64: Use clone for immutable objects when passing or receiving object references to mutable objects.
Praxis 65: Use inheritance or delegation to define immutable classes.
Praxis 66: Call super. clone when implementing a clone method.
Praxis 67: Do not rely on finalize methods for non-memory resource cleanup.
Praxis 68: Use care when calling non-final methods from constructors.
Appendix: Learning Java.
Further Reading.
Index.
Colophon. 0201616467T04062001



Back to Top

商品描述(中文翻譯)

描述
這本廣泛的指南可以幫助不同專業程度的學生更全面地理解 Java,並最大化他們的編碼效率。本書的規則基格式探討了 68 個關鍵主題,說明如何改善代碼,提供清晰且撰寫良好的範例和解決方案。所有範例和解決方案都附有詳細的解釋,以達成可運作的解決方案。這種實用的編程和設計方法描述了經驗豐富的程序員所使用的最佳實踐。要訪問源代碼,請在以下網站註冊本書:http://www.awl.com/cseng/register

適合的課程
Java--中級編程。

目錄
前言。
致謝。
一般技術。
實踐 1:了解參數是按值傳遞,而不是按引用傳遞。
實踐 2:對於常量數據和常量對象引用使用 final。
實踐 3:了解所有非靜態方法默認可以被覆蓋。
實踐 4:在數組和 Vector 之間仔細選擇。
實踐 5:偏好多態性而非 instance of。
實踐 6:僅在必要時使用 instance of。
實踐 7:當對象引用不再需要時,將其設置為 null。

對象與相等性。
實踐 8:區分引用類型和基本類型。
實踐 9:區分 == 和 equals。
實踐 10:不要依賴 equals 的默認實現。
實踐 11:明智地實現 equals 方法。
實踐 12:在 equals 方法實現中偏好使用 get Class。
實踐 13:調用基類的 super.equals。
實踐 14:在 equals 方法實現中仔細考慮 instance of。
實踐 15:實現 equals 方法時遵循這些規則。

異常處理。
實踐 16:了解異常控制流的機制。
實踐 17:永遠不要忽略異常。
實踐 18:永遠不要隱藏異常。
實踐 19:考慮 throws 子句的缺點。
實踐 20:對 throws 子句要具體且全面。
實踐 21:使用 finally 來避免資源洩漏。
實踐 22:不要從 try 區塊返回。
實踐 23:將 try/catch 區塊放在循環外部。
實踐 24:不要使用異常來控制流。
實踐 25:不要對每個錯誤條件使用異常。
實踐 26:從構造函數中拋出異常。
實踐 27:在拋出異常之前將對象返回到有效狀態。

性能。
實踐 28:最初專注於設計、數據結構和算法。
實踐 29:不要依賴編譯時代碼優化。
實踐 30:了解運行時代碼優化。
實踐 31:對於串接,使用 String Buffer 而不是 String。
實踐 32:最小化對象創建的成本。
實踐 33:防範未使用的對象。
實踐 34:最小化同步。
實踐 35:盡可能使用堆疊變量。
實踐 36:使用 static、final 和 private 方法以允許內聯。
實踐 37:僅初始化實例變量一次。
實踐 38:使用基本類型以獲得更快和更小的代碼。
實踐 39:不要使用 Enumeration 或 Iterator 來遍歷 Vector。
實踐 40:使用 System array copy 來複製數組。
實踐 41:偏好使用數組而非 Vector 或 Array List。
實踐 42:盡可能重用對象。
實踐 43:使用延遲評估。
實踐 44:手動優化源代碼。
實踐 45:編譯為本地代碼。

多線程。
實踐 46:了解對於實例方法,同步鎖定對象,而不是方法或代碼。
實踐 47:區分同步靜態和同步實例方法。
實踐 48:使用私有數據和訪問器方法,而不是公共或受保護數據。
實踐 49:避免不必要的同步。
實踐 50:在訪問共享變量時使用 synchronized 或 volatile。
實踐 51:鎖定所有參與單一操作的對象。
實踐 52:以固定的全局順序獲取多個鎖,以避免死鎖。
實踐 53:偏好使用 notify All 而非 notify。
實踐 54:對於 wait 和 notify All 使用自旋鎖。
實踐 55:使用 wait 和 notify All 而不是輪詢循環。
實踐 56:不要重新分配鎖定對象的對象引用。
實踐 57:不要調用 stop 或 suspend 方法。
實踐 58:通過線程協作終止線程。

類別和介面。
實踐 59:使用介面來支持多重繼承。
實踐 60:避免介面中的方法衝突。
實踐 61:當提供部分實現有意義時使用抽象類。
實踐 62:區分介面、抽象類和具體類。
實踐 63:明智地定義和實現不可變類。
實踐 64:在傳遞或接收可變對象的對象引用時,對不可變對象使用 clone。
實踐 65:使用繼承或委派來定義不可變類。
實踐 66:在實現 clone 方法時調用 super.clone。
實踐 67:不要依賴 finalize 方法來清理非內存資源。
實踐 68:在構造函數中調用非 final 方法時要小心。

附錄:學習 Java。
進一步閱讀。
索引。
版權說明。
0201616467T04062001