Java for tomorrow
duminică, 29 decembrie 2013
commonality/variability analysis
Recently I've read some articles about the commonality/variability analysis. I'll try to give some notions then a little example.
Coplien’s work on commonality/variability analysis tells us how to find variations in the problem domain and identify what is common across the domain. Identify where things vary (commonality analysis) and then identify how they vary (variability analysis).
Variability analysis reveals how family members vary. Variability only makes sense within a given commonality.
Commonality analysis seeks structure that is unlikely to change over time, while variability analysis captures structure that is likely to change. Variability analysis makes sense only in terms of the context defined by the associated commonality analysis. From an architectural perspective, commonality analysis gives the architecture its longevity; variability analysis drives its fitness for use.
In other words, if variations are the specific concrete cases in the domain, commonality defines the concepts in the domain that tie them together. The common concepts will be represented by abstract classes. The variations found by variability analysis will be implemented by the concrete classes (that is, classes derived from the abstract class with specific implementations).
I'll present an example in the next post.
sâmbătă, 7 decembrie 2013
Java Generics and Collections (book review)
I've just finished reading the Java Generics and Collections book by Maurice Naftalin & Philip Wadler. Actually, I read it twice and probably I will read it again after some time. It's not too hard to understand, don't get me wrong, just it has so much information and theories and ideas that it's hard to catch them all from a first read. Or, maybe it's just me who didn't caught it :).
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:
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.
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.
vineri, 6 decembrie 2013
Welcome!
Hi, I am a woman, a wife, a mother, a Java developer for ever :)
Between all these jobs, I'm trying to be in touch with everything new and old in Java world. This blog appeared with my necessity to share with you my thoughts about what I think to be interesting enough to share.
Hope you'll enjoy it!
Between all these jobs, I'm trying to be in touch with everything new and old in Java world. This blog appeared with my necessity to share with you my thoughts about what I think to be interesting enough to share.
Hope you'll enjoy it!
Abonați-vă la:
Postări (Atom)