Preface

Why another book on OOP in Java?

I’ve been a writer on Quora for a few years now. I really enjoy it. I get to interact with people from all over the world about a subject I love - the craft of designing good software. I started learning this craft in 1981. I haven’t finished yet.

This book came about after seeing a common thread amongst new Java developers on Quora. Many of them thought OOP in Java was ‘verbose’ or ‘complex’ or ‘outdated’. And that it needed ‘getters and setters’ everywhere.

Yet we’ve had great books on Java, as well as classics on OOP.

So what changed?

Here’s my theory. All the great books were written in the 1990s - before some of our modern Java developers were even born. The reason nobody knows the lessons in them is simple. We don’t teach them anymore.

This book is my distillation of those classic ideas plus a twist of experience. Each chapter contains stuff I actually use, day to day, to get results. It’s full of hard-won wisdom from 25 years at the code face. It’s practical. And very simple. Bugs hide in complexity. I like to give bugs no place to hide.

My hope is this book gets you past ‘getter and setter’ coding and gets you into high gear using objects as they were intended to be used. It might be your first insight into how OOP fits together in the real world. Java has a reputation for being verbose. I hope this book shows you how to fix that. I want you to take away the techniques of crafting clean, powerful, readable OOP code.

This book is not an introduction to Java. It should be suitable for beginners who can write Java “Hello World” and understand the basic syntax for variables, conditionals and classes. Examples use Java 11 syntax. Many work in Java 1.

Alan Mellor
Rock Cottage
February 2021