UML for Java Programmers

by Robert C. Martin

This is a great book for learning or improving with UML. Topics are introduced at a level appropriate for beginners but each topic progresses at a nice pace into intermediate territory. There’s even advice in here suitable for the best programmers I know.

I love the liberal use of source code throughout this book. We model in order to write code and Bob Martin clearly presents that perspective in this book. If code is the goal then it is worthwhile understanding the relationship between our models and our code. While all of the example code is in Java I’d still recommend this book to anyone who wants to learn more about modeling and who has even a passing familiarity with Java. C++ or other programmers should have no problem reading it, for example.

I like that the author goes beyond just describing each of the UML diagrams and takes the opportunity to teach good design while he’s at it. As just one example, the “Single Responsibility Principle (SRP)” is discussed. This principle tells us that “a class should have only one reason to change.” In other words, don’t put everything into one class. That’s pretty obvious but it’s still a common mistake. The book shows a brief snippet of Java code that violates this principle and then shows the UML for how to design it better. More importantly, we’re told how to recognize this problem in UML diagrams we create or inherit.

This book addresses one of the big problems I’ve had with many other UML books–it tells the reader right upfront that not all diagrams are equally important. I love that the author tells us things like that “in the last decade I think I have drawn less than a dozen object diagrams of this kind.” That’s great to know! Because many other books try to cover every diagram and modeling technique they all end up appearing equally important. In this book Bob Martin tells us that he’s only going to cover what we really need to know to be better Java programmers. He achieves that goal with flying colors.