The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms...
Kick off your book project in 2 hours, get started with GhostAI in 2 hours, or do both! Free live workshops, on Zoom. You’ll leave with a real book project and a clear plan to keep going. Saturday, June 27, 2026.
Bought separately
$53.95
Minimum price
$32.99
$34.99
About the Bundle
Everything you need to get up to speed with the latest version of Java
About the Books
✅ Complete beginners who've never written code before ✅ Self-taught developers who need structured learning ✅ Career changers entering software development ✅ Students learning Java in school ✅ Professionals from other languages moving to Java ✅ Anyone who found other Java books too confusing
What You'll BuildBy the end of this book, you'll have created:
Modern Java Design Patterns: A Comprehensive Guide for Java 21–25 is a ground-up rewrite of the design patterns canon for the era of records, sealed classes, virtual threads, and pattern matching for switch. Written for professional Java developers who already know the classics and want to write them the way Java now intends, the book works through every major GoF pattern and a curated set of modern concurrency and functional patterns — each presented with a clear Classic versus Modern comparison so you always understand not just the what, but the why of each evolution.
The book is organised into eight parts that build from language foundations through to production-ready patterns and an appendix suite designed for day-to-day reference.
Part I opens with the modern Java foundations that underpin every pattern in the book: records, sealed interfaces, pattern matching for instanceof and switch, virtual threads, ScopedValue, and StructuredTaskScope. Readers who are already fluent in these features can treat Part I as a quick reference; those newer to the Java 21+ landscape will find a concise, example-driven orientation that pays dividends across every chapter that follows.
Parts II through IV cover the full GoF catalogue — Creational, Structural, and Behavioural patterns — methodically. Each chapter opens with the classic implementation, identifies exactly which friction points modern Java eliminates, and presents a rewritten version using the most appropriate current-language idioms. The Singleton chapter, for instance, moves from double-checked locking to the enum-based approach and then to the injection-framework model. The Strategy chapter replaces the classic interface-and-class hierarchy with a sealed interface and records dispatched by an exhaustive switch expression. The Visitor chapter trades the accept/visit ceremony for a Function over a sealed hierarchy with pattern matching — cutting the code by more than half while gaining compile-time exhaustiveness checking the original pattern never had.
Part V addresses concurrency patterns with the full weight of Project Loom behind them. The chapters on Virtual Thread Executor, Structured Concurrency, and ScopedValue-based context propagation replace patterns that were necessarily complex when platform threads were the only option. The ThreadLocal memory-leak anti-pattern is covered in depth, with a complete migration guide to ScopedValue that goes beyond toy examples to show how context inheritance works inside a StructuredTaskScope.
Part VI introduces patterns that have no direct GoF equivalent because they arise from Java's functional and algebraic capabilities: Algebraic Data Types built from sealed classes and records, Result/Either types for railway-oriented error handling without exceptions, and functional pipeline composition using the Streams API and function combinators.
Part VII is a dedicated anti-patterns chapter — an unusual inclusion that reflects how patterns can be applied incorrectly just as easily as correctly. It covers misuses specific to modern Java: breaking record immutability through mutable components, pooling virtual threads (which defeats their purpose), reaching for ReentrantLock when synchronized is now the right choice post-JEP 491, and over-applying pattern matching in hierarchies that would be better served by polymorphism. Each anti-pattern is shown with a concrete before-and-after so the correction is unambiguous.
Part VIII provides three reference appendices: a Java version feature matrix from Java 16 through 25 showing exactly when each language feature was finalized; a pattern decision tree for navigating to the right pattern from a plain-English problem statement; and a before/after cheat sheet mapping every classic pattern to its modern counterpart at a glance. A fourth appendix covers IDE configuration for preview features in both IntelliJ IDEA and VS Code, including the Maven and Gradle build file changes required to enable preview compilation.
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms...
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.
Learn more about writing on Leanpub
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!
Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.
Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.