The book is divided into two big parts: generics and collections. The generics part begins with an example of List used without generics as it was before Java 5, where the cast was needed and presents the same example with generics, so generics come with the following guarantee:
"Cast-iron guarantee: the implicit casts added by the compilation of generics never
fail. It keeps things
simple, in that generics do not add anything fundamentally new. It keeps things small,
in that there is exactly one implementation of List, not one version for each type. And
it eases evolution, since the same library can be accessed in both nongeneric and generic
forms. "
The introduction is then followed by the description of subtyping and wildcards, when to use extends, when to use super, when none. Worth notifying is the Get and Put Principle:
".. use an extends wildcard when you only get values out of a structure, use a super wildcard when you only put values into a structure, and don’t use a wildcard when you both get and put."
With a base to start with, the following chapters describe the comparison and bounds, how the evolution from legacy code should be done, what is reification and how some of the design patterns use generics. I think there is a lot of information to process and to try on, even for some advanced Java developers.
The second part of the book, collections, begins with a presentation of the Iterators, how to use them, when, what are the restrictions, how to check the efficiency with the O-notation. After this introduction there is a whole chapter for each of the big interfaces that represent the collections of the Java: sets, queues, lists and maps. We can find the review of an old and better known implementation as the HashSet, but also the new thread-safe versions as ConcurrentSkipListSet.
There were some of the implementations that I never used and some that I even never heard of, as IdentityHashMap. It's important to mention that each chapter gives a comparing table that describes the efficiency of each implementation depending of the needed operation.
I liked reading this book, it is for good and all one of my Top 5 Must Read Java books for advanced developers.
Niciun comentariu:
Trimiteți un comentariu