Cover....2
Title Page....3
Copyright Page....4
Dedication Page....5
About the Author....6
About the Reviewer....7
Acknowledgement....8
Preface....9
Table of Contents....15
1. Understanding Domain-driven Design....23
Introduction....23
Structure....24
Objectives....24
Importance of domain-driven design....25
Connecting business goals with technical implementation....27
Core concepts and methodologies....28
Strategic aspect of DDD....30
Tactical aspect of DDD....30
Conclusion....31
Points to remember....32
Multiple choice questions....32
Answers....34
References....34
2. Strategic DDD Concepts....36
Introduction....36
Structure....36
Objectives....37
Domains and subdomains....37
Example scenario with EcoTrack Logistics....39
Understanding bounded contexts....41
Context mapping techniques....44
Aligning business strategy with software design....46
Conclusion....47
Points to remember....47
Multiple choice questions....48
Answers....49
References....50
3. Tactical DDD Implementation....51
Introduction....51
Structure....51
Technical requirements....52
Objectives....52
Entities and value objects....52
Entities pitfalls....54
Builders and domain-specific language....60
Value object....62
Aggregates and aggregate roots....66
Services and their roles....69
Implementing repositories....73
Conclusion....75
Points to remember....76
Multiple choice questions....77
Answers....78
References....79
4. Testing and Validating DDD Applications....81
Introduction....81
Structure....82
Technical requirements....82
Objectives....82
Introduction to testing in DDD....83
Unit testing DDD components....83
Defining the domain components....85
Using tests to validate expected behavior....87
Enhancing your tests....93
Using ArchUnit for architectural validation....97
Conclusion....100
Points to remember....101
Multiple choice questions....102
Answers....104
References....104
5. DDD in Microservices, Monoliths, and Distributed Systems....106
Introduction....106
Structure....107
Technical requirements....107
Objectives....108
DDD in monolithic architecture....108
Creating the domain layer and organizing packages....112
Creating the application layer....117
Creating the controller layer....118
Creating the infrastructure layer....120
DDD in microservices architecture....121
Need for microservices....126
Applying DDD in distributed systems....128
Refactoring legacy code to align with DDD principles....131
Conclusion....134
Points to remember....134
Multiple choice questions....135
Answers....137
References....138
6. Integrating DDD with Clean Architecture....139
Introduction....139
Structure....139
Technical requirements....140
Objectives....140
Overview of Clean Architecture....140
Combining DDD with Clean Architecture....143
Creating well-defined boundaries with Clean Architecture and DDD....143
Creating a bridge between the core application and external systems....146
Structuring code for maintainability....149
Using and combining each approach....151
Conclusion....152
Points to remember....153
Multiple choice questions....154
Answers....156
References....156
7. DDD and Data Modeling....158
Introduction....158
Structure....158
Technical requirements....158
Objectives....159
Principles of DDD in data modeling....159
Modeling data in SQL databases....162
Jakarta Persistence in action....163
Modeling data in NoSQL databases....167
Conclusion....171
Points to remember....171
Multiple choice questions....172
Answers....175
8. Enterprise Java with Jakarta EE....176
Introduction....176
Structure....176
Technical requirements....177
Objectives....177
Applying DDD with Jakarta EE....178
Leveraging Jakarta Data for better encapsulation....180
Integrating DDD into enterprise Java applications....183
Conclusion....187
Points to remember....187
Multiple choice questions....188
Answers....191
9. Enterprise Java with Spring....192
Introduction....192
Structure....192
Technical requirements....193
Objectives....193
Overview of Spring Framework with DDD....193
Applying DDD with Spring Boot....196
Creating and setting up a new Spring Boot project....196
Defining the core domain entities....197
Shaping the repository and services....198
Exposing the service through REST endpoints....200
Polishing error handling....202
Ensuring code behavior with unit tests....204
Conclusion....208
Points to remember....208
Multiple choice questions....209
Answers....211
10. Eclipse MicroProfile and Domain-driven Design....212
Introduction....212
Structure....212
Technical requirements....213
Objectives....213
Understanding Eclipse MicroProfile and its purpose....214
Clarifying Jakarta EE and MicroProfile similarities....214
Eclipse MicroProfile architecture and specifications....215
Integrating Eclipse MicroProfile with DDD....217
Practical microservices example....219
Conclusion....229
Points to remember....230
Multiple choice questions....230
Answers....233
References....233
11. Quarkus and Domain-driven Design....235
Introduction....235
Structure....235
Technical requirements....236
Objectives....236
Quarkus, Jakarta EE, and MicroProfile integration....236
Quarkus in action....238
Creating and setting up a new project....239
Configuring the database integration....239
Panache entity and resource code generation....240
Validating the application's behavior....241
Using Active Record with Panache....242
Using the Repository pattern with Panache....246
Using Panache from a DDD perspective....251
Conclusion....253
Points to remember....253
Multiple choice questions....254
Answers....256
References....257
12. Code Design and Best Practices for DDD....258
Introduction....258
Structure....259
Objectives....259
Anemic model vs. rich model....259
Fluent API vs. Builder pattern in DDD....264
Exception handling and logging in DDD....268
Defining the exceptions hierarchy....268
Creating trackable exception messages....270
Handling exceptions and logs securely....270
Long-term code quality and sustainability....274
Conclusion....276
Points to remember....277
Multiple choice questions....278
Answers....281
References....281
13. Final Considerations....282
Introduction....282
Structure....282
Technical requirements....283
Objectives....283
Introduction to domain storytelling....283
Purpose and benefits of domain storytelling....284
Differences between domain storytelling and agile brainstorming....285
Exploring domain storytelling....287
Further reading and continued exploration....292
Conclusion....292
Points to remember....293
References....294
Index....295
Domain-driven Design (DDD) continues to shape how modern software systems are built by bridging the gap between technical teams and business needs. Its emphasis on modeling the domain with precision and clarity is especially relevant in today’s fast-paced, complex software landscape.
This book begins with DDD fundamentals, including core principles, a shared language, and the distinction between strategic and tactical approaches, progressing to strategic concepts like bounded contexts, context mapping, and domain events. It explores the tactical Java implementation detailing entities, value objects, services, aggregates, and repositories. The book also explores testing strategies and architectural validation using ArchUnit/jMolecules. Further, it explores DDD across microservices, monoliths, and distributed systems, integrating with Clean Architecture and SQL/NoSQL data modeling to prevent impedance mismatch. It thoroughly covers applying DDD within Jakarta EE, Spring, Eclipse MicroProfile, and Quarkus.
By the end, you will be equipped to model business logic more effectively, design systems that reflect real-world domains, and integrate DDD seamlessly into enterprise applications. You will gain clarity, confidence, and the tools needed to build software that delivers business value.
This book is ideal for Java developers, software architects, tech leads, and backend engineers. It is especially valuable for professionals designing scalable enterprise systems or applying DDD in modern software architecture.