The Research Behind the Book
Java by Comparison grew out of a teaching concept for clean code that we developed, applied, and evaluated at the University of Bamberg for more than six years.
Teaching Clean Code, Not Just Working Code
Programming courses at university usually grade functional correctness. Code that works but is hard to read and maintain passes, although the software industry needs developers who write clean code. Our courses put clean, maintainable code first.
The concept, which received the faculty's teaching award, works like this:
- Group assignments. Students in their second and third year solve four programming assignments per semester in teams.
- Detailed textual code review. Every submission gets a review that explains what is wrong with the code, how to write it better, and why the better version is really better.
- A knowledge base of before/after comparisons. Over the years, we noticed that we told every new generation of students the same things. We collected the typical issues of Java learners as comparisons of flawed and improved code. A reviewer only needs to reference the matching comparison, which makes feedback faster and better: students see the problem and the rationale behind the solution.
- Curated static analysis checks. A selected set of static code analysis rules helps reviewers spot violations quickly.
That knowledge base became the book. Its 70 items are based on code we faced when correcting our students' programming assignments.
Publications
Teaching Clean Code
Presents the feedback-driven teaching concept for clean code and evaluates one semester of student submissions (n=18) with static code analysis tools, which shows steady progress. It identifies the correction of assignments as the bottleneck for scaling the course and proposes the knowledge base of before/after comparisons, plus curated static analysis checks, to shorten the time to feedback.
BibTeX
@inproceedings{dietz2018teaching,
author = {Linus W. Dietz and Johannes Manner and Simon Harrer and J{\"o}rg Lenhard},
title = {Teaching Clean Code},
booktitle = {Proceedings of the 1st Workshop on Innovative Software Engineering Education (ISEE 2018)},
series = {CEUR Workshop Proceedings},
volume = {2066},
pages = {24--27},
year = {2018},
url = {https://ceur-ws.org/Vol-2066/isee2018paper06.pdf}
}
Code Process Metrics in University Programming Education
Mines the Git repositories of 38 student teams in two Bamberg courses, Advanced Java Programming and Introduction to Parallel and Distributed Programming, which use Java by Comparison to point students to issues in code reviews. It analyzes how eight code process metrics relate to students' scores and finds only weak correlations.
BibTeX
@inproceedings{dietz2019codeprocess,
author = {Linus W. Dietz and Robin Lichtenth{\"a}ler and Adam Tornhill and Simon Harrer},
title = {Code Process Metrics in University Programming Education},
booktitle = {Proceedings of the 2nd Workshop on Innovative Software Engineering Education (ISEE 2019)},
series = {CEUR Workshop Proceedings},
volume = {2308},
pages = {23--26},
year = {2019},
url = {https://ceur-ws.org/Vol-2308/isee2019paper05.pdf}
}
From the Classroom to Industry: The Kata
We turned the method into a two-hour team exercise. Pairs clean up deliberately uglified legacy code and may only apply comparisons from the book. At the first run, at the BMW Group coding dojo on March 25, 2019:
- 19participants
- 39 / 70comparisons used
- 120minutes
The teams favored the chapters Name Things Right and Start Cleaning Up. The most used comparisons were Avoid Abbreviations and Avoid Negations: quick fixes with a large effect on readability. Run the kata with your team.
Teaching with the Book
- In code reviews and grading. Point students to the matching item instead of writing the same explanation again. Each item shows the problem and the solution side by side.
- Alongside any programming course. Once students know basic Java syntax, the book can accompany basically any course with programming tasks. A FizzBuzz exercise is a good readiness check.
- For coaching junior developers. Senior developers use it the same way in industry.
- With the free material. The preface and three items are free samples, and the kata with code and tests is on GitHub.
Do you teach with Java by Comparison or research code quality in education? Get in touch, we are happy to list your course.
How to Cite the Book
Simon Harrer, Jörg Lenhard, Linus Dietz. Java by Comparison: Become a Java Craftsman in 70 Examples. The Pragmatic Bookshelf, Raleigh, NC, 2018. ISBN 978-1-68050-287-9.
@book{harrer2018javabycomparison,
author = {Simon Harrer and J{\"o}rg Lenhard and Linus Dietz},
title = {Java by Comparison: Become a Java Craftsman in 70 Examples},
publisher = {The Pragmatic Bookshelf},
address = {Raleigh, NC},
year = {2018},
isbn = {978-1-68050-287-9},
url = {https://pragprog.com/titles/javacomp/java-by-comparison/}
}