Effective Java

Effective Java is one of must-read books for every Java programmer. Certainly this book does not introduce Java syntax, it does not instruct what Java libraries or frameworks are popular. Instead it explains best practices of Java programming in detail. This book makes you how to code in Java like an expert.


This book covers 11 topics as the following:

  • Creating and Destroying Objects
  • Methods Common to All Objects
  • Classes and Interfaces
  • Generics
  • Enums and Annotations
  • Lambda and Streams
  • Methods
  • General Programming
  • Exceptions
  • Concurrency
  • Serialization

The first three chapters talks about how to start Java code designs. Instead of constructors, you should consider other methods like factory and builder. Which and how you should implement common methods like toString, equals, hashCode. Some rules are actually parts of Object-Oriented Design principles.

The next three chapters involves some key usages of Java: Generics, primitive types, auto-unboxing and Collections are commonly used and you should know how to use them correctly. Enum and Annotations are very useful and you could efficiently code with them. Lambda and Streams, which are two of most important features since Java 8, are preferred and used judiciously.

The following three chapters are more how to code better generally and some of the rules are applicable to other languages. The last two chapters are Java specific. It gives kind of guidelines how to use them carefully.

This book, in my opinions, is essential for those who have intermediate Java knowledge and want to advance the skills. Especially after you finish some fundamental books like hello world style, you will learn what should be better in terms of maintainability, performance and prevention of loop-hope. For example, you will learn why builders are used instead of just parameterised constructors. try-with-resource is favoured. for-loop syntax should be wisely used with Collections rather than just for(int i=0; i<length; i++).

Another preferred feature of this book is to compare common mistakes and correct usage to explain the importance of the rules. For example it compares a typical getter implementation (just return a field) and defensive copies in getter to prevent internal change of immutable objects.

Generally speaking, the main ideas of this book are compliance of OOD principles, maintainable and safe codes (type-safe, thread-safe, testable) as well as well documentation with JavaDoc. A senior Java developer should well understand the ideas and coach his subordinates to write beautiful Java codes with the principles.

Comments

Popular posts from this blog

Event: Developer Productivity Engineering: What's in it for me?

Mark Six Analyst

Pluses and Minuses: How Math Solves Our Problems