Google Plus Logo
Twitter Logo
Facebook Logo

Effective Java, second edition – Book Review

Before reading that book, I read the translation in French of the first edition, but I've thinked that it will be interesting to read the second edition and this time in English.

Effective Java Cover

This book is the book to read if you want to write good Java code. All the advices are really useful. It's really comfortable to read book from a person who master Java. In fact, Joshua led the design and implementation of numerous Java features.

The book is separated into 10 chapters :

  1. Creating and destroying objects : This first chapter is about how to create the objects. It describes methods to improve the creation of objects, like static factories, builders or singletons.
  2. Methods common to all objects : This chapter explains how, and when, to implement the equals, hashCode, clone, toString and compareTo methods. Here, the contract of these methods  are described and explained and the examples show you how to code these methods.
  3. Classes and interfaces :  Here, we learn how to use the interfaces and abstract classes to have a good design. It describe also when to use inheritance or composition.
  4. Generics :This chapter explains how to work with generics. We learn how to avoid unchecked warnings and how to create generics methods.
  5. Enum and annotations : The fifth chapter is about the use of enums and annotations in your API. We learn how to create powerful enums and annotations to improve code. We also learn how to use the power of these two concepts to create flexible and powerful code.
  6. Methods : This chapter cover the creation of methods. How to write them, what to do with the parameters and what to return from a method.
  7. General programming : Here you'll found about 10 general advices like avoiding float and double if exact answers are needed or avoid wrappers.
  8. Exceptions : This chapter teach you how to work with exceptions and how to create code that throws exceptions.
  9. Concurrency : Here you will learn what you to use when you need to work with several threads. It shows what the standard API contains for concurrency utilities. Moreover you will see what to avoid to use when making concurrent programs.
  10. Serialization :  The last chapter is about the serialization. We'll see how to make a class Serializable and how to work with Serializable classes. We see also several advanced techniques (readResolve or serialization proxies) for instance control.

If you follow the advices of all the chapters, you'll be able to create really flexible, maintainable and usable API.

To conclude, I must say that this book must be read by every advanced programmers. It's not a book to learn Java from the basis, but a book to learn how to write good Java especially how to create API for others.


Comments powered by Disqus