-
2011
Two new Java courses
At the University of Bamberg, Simon Harrer and Jörg Lenhard designed two courses: Advanced Java Programming and Programming Complex Interactive Systems, a course on concurrency on the JVM.
A typical university course has a theoretical lecture, a plenary exercise, homework, and a written exam. Students hand in a solution and get a grade. That teaches them to make code work. It does not teach them to write code that others can read and change.
-
The question
How do you teach clean code?
Our answer was code review, in three steps:
- Experience code reviews interactively, in class.
- Receive detailed written code reviews on every assignment.
- Perform code reviews yourself.
Students worked in groups on real programming assignments, and every submission came back with a detailed review of what was wrong, how to do it better, and why the better way is really better.
-
2011–2016
The same mistakes, again and again
In six years, we
- 500+assignments reviewed
- 1,000,000+lines of Java read
- 1000sof times flagged the same issues
Every new generation of students made the same mistakes, and we wrote the same explanations. So we started a collection of typical errors, each as a comparison of flawed and improved code, to point students to instead of writing it all again.
-
2016
A teaching award, and 80 out of 80 points
The course concept received the faculty's teaching award. For the first time, a student group scored 80 out of 80 points. Simon and Jörg handed the course over into competent hands, and it was time to look for new challenges.
-
The idea
"Can we make something great out of it?"
Six years of reviews had produced a format that worked: every comparison has an actionable name, the bad code with a problem description, and the better code with a solution description.
The anatomy of a comparison We proposed the book to The Pragmatic Bookshelf. Three days later, we had the contract.
-
2016–2018
18 months of writing
- 3authors
- 18months
- 16technical reviewers
- 300+beta readers
Together with an editor, a copy editor, a layouter, and a foreword, we turned the collection into 70 comparisons in nine chapters, from cleaning up booleans to preparing code for the real world.
-
March 21, 2018
Java by Comparison is released
Enthusiastic reviewers and happy readers followed: reviews in magazines, blogs, and podcasts in five languages, and the authors told the story in talks at meetups and conferences, always ending with a round of Comparison Jeopardy, a game where the audience finds the name of a comparison.
-
2019 and later
Beyond the book
- 2019: The Java by Comparison kata, first run at the BMW Group coding dojo.
- 2020: The Korean translation 자바 코딩의 기술 by Gilbut.
- 2021: New comparisons online, on Java concurrency and modern Java.
2025: Java by Comparison is one of the books in the Bartz v. Anthropic copyright settlement, the class action over books used to train Anthropic's Claude models. So, in a way, its 70 comparisons live on in Anthropic's frontier models.
The research behind the teaching concept is published in peer-reviewed papers: see the research page.
The Story of the Book
Java by Comparison did not start as a book. It started in a classroom, with a simple question: how do you teach others to write clean code?