Practical Java Programming Language Guide

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:在數組和向量之間仔細選擇
實踐5:優先使用多態性而不是instanceof
實踐6:只在必要時使用instanceof
實踐7:當不再需要對象引用時,將其設置為null
對象和相等性
實踐8:區分引用類型和基本類型
實踐9:區分==和equals
實踐10:不要依賴於equals的默認實現
實踐11:明智地實現equals方法
實踐12:在equals方法實現中優先使用getClass
實踐13:調用基類的super.equals
實踐14:在equals方法實現中仔細考慮instanceof
實踐15:在實現equals方法時遵循這些規則
異常處理
實踐16:了解異常控制流的機制
實踐17:永遠不要忽略異常
實踐18:永遠不要隱藏異常
實踐19:考慮throws子句的缺點
實踐20:使用throws子句時要具體和全面
實踐21:使用finally避免資源洩漏
實踐22:不要從try塊返回
實踐23:將try/catch塊放在循環外面
實踐24:不要將異常用於控制流程
實踐25:不要將異常用於每個錯誤條件
實踐26:從構造函數中拋出異常
實踐27:在拋出異常之前將對象返回到有效狀態
性能
實踐28:最初關注設計、數據結構和算法
實踐29:不要依賴於編譯時代碼優化
實踐30:了解運行時代碼優化
實踐31:使用StringBuffer而不是String進行連接
實踐32:最小化對象創建的成本
實踐33:防止未使用的對象
實踐34:最小化同步
實踐35:盡可能使用堆疊變量
實踐36:使用靜態```