Written for the working Java developer, Joshua Bloch's Effective Java Programming Language Guide provides a truly useful set of over 50 best practices and tips for writing better Java code. With plenty of advice from an indisputable expert in the field, this title is sure to be an indispensable resource for anyone who wants to get more out of their code.
As a veteran developer at Sun, the author shares his considerable insight into the design choices made over the years in Sun's own Java libraries (which the author acknowledges haven't always been perfect). Based on his experience working with Sun's best minds, the author provides a compilation of 57 tips for better Java code organized by category. Many of these ideas will let you write more robust classes that better cooperate with built-in Java APIs. Many of the tips make use of software patterns and demonstrate an up-to-the-minute sense of what works best in today's design. Each tip is clearly introduced and explained with code snippets used to demonstrate each programming principle.
Early sections on creating and destroying objects show you ways to make better use of resources, including how to avoid duplicate objects. Next comes an absolutely indispensable guide to implementing "required" methods for custom classes. This material will help you write new classes that cooperate with old ones (with advice on implementing essential requirements like the equals() and hashCode() methods).
The author has a lot to say about class design, whether using inheritance or composition. Tips on designing methods show you how to create understandable, maintainable, and robust classes that can be easily reused by others on your team. Sections on mapping C code (like structures, unions, and enumerated types) onto Java will help C programmers bring their existing skills to Sun's new language. Later sections delve into some general programming tips, like using exceptions effectively. The book closes with advice on using threads and synchronization techniques, plus some worthwhile advice on object serialization.
Whatever your level of Java knowledge, this title can make you a more effective programmer. Wisely written, yet never pompous or doctrinaire, the author has succeeded in packaging some really valuable nuggets of advice into a concise and very accessible guidebook that arguably deserves a place on most any developer's bookshelf. --Richard Dragan
Topics covered:
Best practices and tips for Java
Creating and destroying objects (static factory methods, singletons, avoiding duplicate objects and finalizers)
Required methods for custom classes (overriding equals(), hashCode(), toString(), clone(), and compareTo() properly)
Hints for class and interface design (minimizing class and member accessibility, immutability, composition versus inheritance, interfaces versus abstract classes, preventing subclassing, static versus nonstatic classes)
C constructs in Java (structures, unions, enumerated types, and function pointers in Java)
Tips for designing methods (parameter validation, defensive copies, method signatures, method overloading, zero-length arrays, hints for Javadoc comments)
General programming advice (local variable scope, using Java API libraries, avoiding float and double for exact comparisons, when to avoid strings, string concatenation, interfaces and reflection, avoid native methods, optimizing hints, naming conventions)
Programming with exceptions (checked versus run-time exceptions, standard exceptions, documenting exceptions, failure-capture information, failure atomicity)
Threading and multitasking (synchronization and scheduling hints, thread safety, avoiding thread groups)
Serialization (when to implement Serializable, the readObject(), and readResolve() methods)
Joshua Bloch is chief Java architect at Google and a Jolt Award winner. He was previously a distinguished engineer at Sun Microsystems and a senior systems designer at Transarc. Bloch led the design and implementation of numerous Java platform features, including JDK 5.0 language enhancements and the award-winning Java Collections Framework. He coauthored Java™ Puzzlers (Addison-Wesley, 2005) and Java™ Concurrency in Practice (Addison-Wesley, 2006).
Creating and Destroying Objects 1, Consider providing static factory methods instead of constructors Pros: Named methods Flexible: not required to create a new object each time invoked. Flexible: can provide an object of any subtype. Cons The class without ...
评分坐在那里看了一个小时,看的心浮气躁,完全看不下去任何内容。一个小时过去了连一个章节都没看完。也可能是因为没带笔,直接看感觉特别烦躁。看来看去只感觉,这本书在讲什么,这段话在讲什么?估计我修炼还不到家。我先看看别的吧,提高提高自己技术再来看好了,毕竟这本书评...
评分个人认为这本书和《Thinking in java》一样,并不适合刚入门JAVA的人。它是一本进阶教程,里面的多线程或者设计模式,是需要一定的功力才能够理解作者所举的示例的。每个示例解释得恰到好处,可以作为实际开发的指导原则了吧,若有一些开发经验或者将作者所举的原则应用到实际...
评分抱歉没有购买正版图书!该书内容同样不太适合完全没有java基础或者是java实战经验较少的同学阅读。与很多偏向编程技巧书籍类似,若没有一定的实战经验,很难去理解作者全书中讲解的奇淫异术,不过新手也可以作为基础知识学习的扩展,不至于“第一份”代码因为缺少太多实战...
评分首先声明,这本书的中文翻译大体上还是过得去的,大方向上没问题。 ----------------------------分割线---------------------------- 1. p129 翻译:Java的枚举类型是功能十分齐全的类,功能比其他语言中的对等物要更强大得多,Java的枚举本质上是int值。 原文:Java's enum ...
读完《Effective Java: Second Edition》,我最大的感受就是,原来Java开发可以这么“讲究”。这本书不是那种让你看了之后立马就能写出“高大上”代码的书,它更多的是在培养你的“Java编程思维”。作者 Joshua Bloch用他深厚的功力,把Java语言的设计哲学和最佳实践,以一种近乎“艺术”的方式呈现出来。 书中关于“优先考虑使用接口而不是实现类”的解释,让我深刻理解了“依赖倒置原则”在实际应用中的重要性。我之前也知道这个原则,但总是觉得有点抽象,直到看了这本书,才明白它对于代码的可扩展性、可测试性有多么大的影响。作者通过生动的例子,把抽象的概念变得具体可感,让我不再是“纸上谈兵”。而且,这本书的结构非常清晰,每个“条目”都聚焦于一个具体的问题,并且给出了清晰的解决方案和原因分析,非常适合碎片化阅读,也便于随时查阅。
评分《Effective Java: Second Edition》这本书,对我来说,更像是一本“内功心法”。它没有直接教你“招式”,而是让你去理解“力道”和“节奏”。我以前写Java代码,总感觉是在“堆砌”代码,追求的是功能的实现。但这本书让我看到了代码的“生命力”,以及如何让它变得更“健壮”、“高效”和“优雅”。 我印象特别深刻的是关于“如何使用枚举来表示常量”的讲解,之前我一直是用`final static`来定义常量,觉得挺方便的。但是读了这本书,才明白枚举在处理常量集合、保证类型安全以及在某些复杂场景下的优势。作者不仅给出了“为什么”,还给出了“怎么做”,并且解释了背后的设计理念。这种“追根溯源”的学习方式,让我对Java语言的认识更加深刻,也让我自己在写代码时,多了一份审慎和考量。它让我明白,好的代码不仅仅是能运行,更是经得起时间的考验,易于维护和扩展。
评分老实说,我拿起《Effective Java: Second Edition》这本书的时候,内心是抱着一种“学习前人经验,避免自己踩坑”的心态。毕竟,Java这门语言已经发展了很多年,积累了无数的实践经验和教训。而这本书,简直就是这些宝贵经验的精华提炼。它不是那种泛泛而谈、告诉你“应该做什么”的书,而是深入到Java语言的每一个细节,告诉你“为什么这么做”以及“这样做有什么好处”。 举个例子,书中关于“使用对象而不是引用来比较”的讲解,我之前在项目中也遇到过类似的问题,但总是一知半解,有时候能碰巧解决,有时候就莫名其妙地出现bug。读了这本书,我才恍然大悟,原来背后的原因如此清晰,并且作者给出了最有效的避免方法。这种“醍醐灌顶”的感觉,贯穿了整本书。它就像一个经验丰富的老司机,在指导你如何驾驶Java这辆车,让你不仅能开得快,更能开得稳,而且不容易发生意外。
评分这是一本需要反复揣摩的书。我承认,初读的时候,有些章节我可能只是“似懂非懂”,感觉作者在讲一些非常底层、非常精妙的东西,需要静下心来,结合自己的实际开发经验去消化。但正是这种“难啃”的特质,反而让我觉得它价值非凡。这本书没有给任何“万能药”,而是教会你“思考”的方法,让你能够独立地去分析和解决问题。 尤其是在处理并发和性能优化方面,作者的见解非常独到。我记得有一个关于“如何正确使用同步机制”的章节,读完之后,我才意识到自己之前对`synchronized`关键字的理解有多么片面,以及它在多线程环境下的潜在性能影响。作者不仅指出了问题所在,还给出了更优的替代方案,并且详细解释了背后的原理。这种深入骨髓的讲解,让我对Java的理解上升了一个层次,不再是停留在表面的语法层面,而是能够真正掌握其内在的运行机制。
评分这本《Effective Java: Second Edition》真的像一本武林秘籍,不过不是教你如何降龙十八掌,而是让你在Java的江湖里如鱼得水,少走弯路。我拿到这本书的时候,说实话,对Java已经有了一定的了解,觉得自己还算是个“熟练工”。但是读了这本书,才发现自己之前的一些“好习惯”,可能在更高级别的Java开发者看来,简直是“画蛇添足”或者“南辕北辙”。作者( Joshua Bloch)真是个老江湖,他能用最精炼的语言,剖析Java语言设计中的一些微妙之处,以及在实际开发中如何避免那些看似微不足道却可能导致巨大问题的陷阱。 我尤其喜欢他关于“条理清晰的设计”的那几个章节,以前我写代码,总觉得功能实现就好,至于代码是否优雅、易于维护,总是被放到次要位置。这本书让我意识到,清晰的代码结构和设计模式的应用,远比想象中重要得多。它不仅能让你自己以后修改代码时省去大量时间,更能让你的团队成员更容易理解你的意图,大大降低了沟通成本和协作难度。而且,他关于“避免过度设计”的论述也相当到位,告诫我们不要为了使用某种模式而强行套用,而是要根据实际需求来选择最合适的解决方案。这种平衡的观点,在很多技术书中都很难得。
评分字字珠玑,读过之后顿时觉得自己的程序千疮百孔,每一页都有巧妙无比但又实用的技巧与方法。必定要反复过目的经典
评分JLS最佳注解
评分The three-fold learning process: what--Head First Java, how--Java How To Program, and why--Effective Java (and maybe... Thinking in Java)
评分The three-fold learning process: what--Head First Java, how--Java How To Program, and why--Effective Java (and maybe... Thinking in Java)
评分我觉得应该是java进阶的必读书籍之一,受益匪浅,书虽然很薄,但是容纳的知识真的很丰富
本站所有内容均为互联网搜索引擎提供的公开搜索信息,本站不存储任何数据与内容,任何内容与数据均与本站无关,如有需要请联系相关搜索引擎包括但不限于百度,google,bing,sogou 等
© 2026 book.quotespace.org All Rights Reserved. 小美书屋 版权所有