Must-Read Java Books
Chris Roberts
Data Directions, Inc.
Selection Criteria
- Easy to read
- short, digestable sections are good for busy, often-interrupted readers
- coverage of topics is more broad than deep
- Easy to apply
- must be able to put the book's ideas into use quickly and without hassle
- incremental approach is preferable
- "Timeless," at least as much as a technology book can be
- "Enlightening" - must present new ideas or old ideas in a new way
The Books
- Effective Java - by Joshua Bloch
- Refactoring: Improving the Design of Existing Code - by Martin Fowler
- Practices of an Agile Developer - by Venkat Subramaniam
- BONUS: Groovy in Action - by Dierk König
Effective Java
- by Joshua Bloch
- Chief Java Architect at Google
- Formerly Distinguished Engineer at Sun
- winner of 2001 Jolt Award
Effective Java - Quick Summary
From the intro:
This book is designed to help you make the most effective use of the
Java programming language and its fundamental libraries, java.lang,
java.util, and, to a lesser extent, java.util.concurrent
and java.io.
Effective Java - Quick Summary
- 10 Chapters
- 78 Items
- Each Item = 1 Rule = 1 Best Practice
Effective Java - Quick Summary
The book covers:
- Object creation and destruction
- Methods on all objects (
equals(), hashCode(), toString())
- Good object-oriented design
- Java 5 Topics: Generics, Enums, Annotations
- Exceptions
- Concurrency
- Serialization
Effective Java - Quick Summary
Examples:
- Item 1: Consider static factory methods instead of constructors.
- Item 8: Obey the general contract when overriding equals.
- Item 16: Favor composition over inheritance.
- Item 43: Return empty arrays or collections, not nulls.
- Item 48: Avoid
float and double if exact answers are required.
Effective Java - Quick Summary
For each item:
- An explanation of the best practice
- The reasoning behind it
- Code example(s), sometimes from the Java API codebase
- Discussion of advantages, disadvantages
- Cross-references
Similar to design pattern books, but not quite as structured.
Effective Java and Selection Criteria, Part 1
- Easy to read
- Short sections
- "The book is not intended to be read from cover to cover: each item stands on its own, more or less."
- Cross-references
- Introduction points to Java 5 topics
- Easy to apply
- Short tips that can be used right away
- Stand-alone items are easy to introduce incrementally
Effective Java and Selection Criteria, Part 2
- Timeless - "Should last as long as Java..."
- Covers low-level language features and API, neither likely to change
- Sections on OOP are transferable to other languages
- Enlightening
- Explains how
equals() and hashCode() are related
- Discusses why getting
equals() right can be really tough (hint: polymorphism)
- Covers underused language features and API
- Covers correct usage of often-misused features
Refactoring: Improving the Design of Existing Code
- by Martin Fowler
- Chief Scientist at Thoughtworks
- OO/UML/patterns/agile guru
- Member of the Agile Alliance
Refactoring - Quick Summary
From the foreword:
This book explains the principles and best practices of refactoring, and points out when and
where you should start digging in your code to improve it. At the book's core is a comprehensive
catalog of refactorings. Each refactoring describes the motivation and mechanics of a proven code
transformation.
-- Erich Gamma
Refactoring - Quick Summary
- Section 1: Intro and Concepts
- An example
- Principles (definition, reasons, problems, performance)
- Code smells
- Tests (including JUnit)
Refactoring - Quick Summary
- Section 2: Refactoring Catalog
- Composing Methods (Extract Method, Inline Method, etc.)
- Moving Features (Move Field, Inline Class, ...)
- Organizing Data (Change Value to Reference, Replace Array with Object)
- Simplifying Conditionals (Decompose Conditional, Introduce Null Object)
- Simplifying Method Calls (Add Parameter, Introduce Parameter Object)
- Generalizations (Pull Up, Push Down, Extract Interface)
- Big Refactorings (Convert Procedural Design to Objects)
Refactoring - Quick Summary
- Section 3: Wrap-Up
- Resources and References
- Refactoring Tools
Refactoring - Quick Summary
For each refactoring:
- Short Description
- Motivation - Why make this change?
- Mechanics - How to make this change
- Example
Similar in structure to most design pattern catalogs.
Refactoring and Selection Criteria, Part 1
- Easy to read
- Short sections
- Stand-alone examples
- Cross-references
- Easy to apply
- Read a few pages, then get to work refactoring
- Make incremental improvements today!
Refactoring and Selection Criteria, Part 2
- Timeless
- Covers "higher-level" concepts related to OOP in general, Java specifically
- Transferable to other languages
- Enlightening
IDEs have refactoring support built-in, but this book
- explains why to use them
- covers when and when NOT to use them
- covers many not available in IDEs (72 total, ~24 in Eclipse)
- covers over 20 code smells
Practices of an Agile Developer
- by Venkat Subramaniam
- Founder of Agile Developer, Inc.
- Frequent conference speaker, especially at No Fluff Just Stuff
- winner of Jolt Productivity Award
Agile Developer - Quick Summary
From the back of the book:
...we've collected the personal habits, ideas, and approaches of successful
agile software developers and compiled them in a series of short,
easy-to-digest tips.
Agile Developer - Quick Summary
- Not Java-specific
- Little code (simple examples in different languages)
- Covers higher-level practices
- Ideas come from XP, Scrum, & elsewhere, but not methodology-specific either
Agile Developer - Quick Summary
This book covers: (Part 1)
- Getting started with agile (the mindset, how to keep it up)
- How to keep users involved
Agile Developer - Quick Summary
This book covers: (Part 2)
- Agile feedback (testing, automation, metrics)
- Agile coding (clear intent, KISS, delegation over inheritance)
- Agile debugging (solutions log, exception-handling)
- Agile collaboration (collective ownership, mentoring, code reviews)
Agile Developer - Quick Summary
Book Structure:
- 10 Chapters
- 45 Tips (mostly 3-5 pages apiece)
Agile Developer - Quick Summary
Tips Structure:
- "The evil demon's whisperings" - A bad, careless, but all-too-common habit
- Discussion of the habit, and how agile does it differently
- "The guardian angel" - Summary of the discussion, key take-away
- "What It Feels Like" - How to know if you're implementing the practice correctly
- "Keeping Your Balance" - How not to overdo or underdo the practice
Agile Developer - Quick Summary
Example Tip: Automate Acceptance Testing (Part 1)
- "All right, so your unit tests verify your code does what you think
it should. Ship it. We'll find out if it's what the customers want soon enough."
- Followed by antecdotes and discussion of FIT (for testing)
- "Create tests for core business logic. Have your customers verify these
tests in isolation, and exercise them automatically as part of your general test runs."
Agile Developer - Quick Summary
Example Tip: Automate Acceptance Testing (Part 2)
- What It Feels Like - "It feels like cooperative unit testing: you're still
writing the tests, but someone else is providing you the answers."
- Keeping Your Balance
- "Use the customer's business logic, but don't get bogged down documenting it
extensively"
- "You may discover previously unknown bugs..."
Agile Developer and Selection Criteria, Part 1
- Easy to read (same points as Refactoring)
- Short sections
- Stand-alone examples
- Cross-references
- Easy to apply
- Pick and choose different practices without necessarily adopting them all at once
- Introduce one new practice every week...
Agile Developer and Selection Criteria, Part 2
- Timeless
- Covers best practices for many projects, regardless of language
- Explains practices as part of a larger "agile mindset"
- "People over process"
- "Tests over documentation"
Agile Developer and Selection Criteria, Part 3
- Enlightening
- Discusses some lower-level practices not found in other agile books
(good commenting practices, providing useful error messages)
- Angel-versus-devil approach helps explain bad programming practices
in a new light
- Great companion to Extreme Programming Explained by Kent Beck,
or other methodology-specific book
- Also great companion to Java Extreme Programming Cookbook by
Eric M. Burke and Brian M. Coyner, or other language-specific book
covering agile toolsets
BONUS: Groovy in Action by Dierk König
Why?
- Polyglot programming is all the rage right now...
- Even if you're skeptical, pick up a book on a non-Java, JVM-based language
- You might be surprised at how much more productive you can become...
- ...but at the very least you'll discover fresh approaches to common problems.
BONUS: Groovy in Action by Dierk König
Plenty to choose from:
- Groovy - dynamic, "lightweight", metaprogramming-friendly
- JRuby or Jython - the goodness of Ruby or Jython plus Java integration
- Scala - OO and functional language hybrid
- Clojure - Lisp on Java
Groovy in Action
- by Dierk König
- Groovy committer since 2004
- Frequent conference speaker
- Contributor to several agile and testing books
Groovy in Action - Quick Summary
From the back of the book:
...a fast-paced tutorial... Java developers will master Groovy's enhancements to
Java such as builders, template engines, and support for regular expressions and
database programming. The book includes dozens of practical examples. It provides
tips and tricks for daily work, unit testing, build support, and even scripting
Windows.
Groovy in Action and Selection Criteria
If you pick Groovy, this book is great.
- Easy to read - Easy to follow, although not in short sections like the others
- Easy to apply - After just a few chapters, you'll be ready to replace UNIX shell scripts, Ant scripts,
unit tests, and small utility programs with Groovy
- Timeless - Okay, it fails this one, unless you count "opening my eyes to the wonders
of dynamic languages on the JVM" at a more meta-level (okay, so I tried)
- Enlightening - If you've never looked at Groovy before, almost everything in this book
will be new to you. See also: "Timeless" comment above.
References
- Effective Java - http://java.sun.com/docs/books/effective/
- Refactoring: Improving the Design of Existing Code - http://www.refactoring.com/
- Practices of an Agile Developer - http://pragprog.com/titles/pad/
- Groovy in Action - http://www.manning.com/koenig/