Learn how to implement DDD, CQRS and Event Sourcing. Understand the theory and put it into practice with jаvascript and Node.js. Utilize an extensive source code bundle and an interactive execution feature for a hands-on experience.
This book explains and illustrates how to implement Domain-Driven Design, Command Query Responsibility Segregation and Event Sourcing. The goal is to build software that is behavior-rich, event-based, problem-centric, reactive, scalable and well-designed. Domain-Driven Design is a way to build software that focuses on the problem to solve and its associated knowledge areas. Command Query Responsibility Segregation separates a software into a write side and a read side. Event Sourcing is an architectural pattern that represents state as a sequence of immutable events. The concepts are explained in theory and put into practice with standalone examples and a Sample Application. This is done without third-party software. The book comes with a source code bundle and supports interactive execution. All code is written in jаvascript and uses Node.js as runtime.
Style of this book
The primary focus of this book is the application and the implementation of concepts. Therefore, the purely theoretical parts are generally concise. The covered topics are illustrated extensively with a large amount of examples and code. Selected conceptual parts are also discussed in greater detail. Apart from Node.js and jаvascript, the book's main content does not utilize or explain specific frameworks or technologies. For functionalities that require persistence or inter-process communication, exemplary implementations are provided that directly work with the filesystem. This includes Repositories, the Event Store, Read Model stores and a remote event distribution. The goal is to convey a deeper understanding of the according concepts. For production purposes, these implementations can be replaced with suitable technologies. This procedure is exemplified in Appendix B.
There are multiple reasons for using Node.js as runtime platform and jаvascript as programming language. One is my personal long-term experience with them. Also, two projects in which I applied CQRS and Event Sourcing made use of both technologies. Another reason for jаvascript is that it is a very widespread language. Even more, its syntax can look similar to other popular languages, such as Java, especially when using classes. Furthermore, this book uses jаvascript for the frontend and shares some code with the backend. One specific reason for Node.js is its simplicity for certain use cases, such as when operating an HTTP server. Finally, jаvascript helps to keep the code examples concise through specific language features such as arrow functions or destructuring assignments.
The content and the code examples in this book compromise a combination of imperative, declarative, object-oriented and functional programming. However, the majority of the implementations apply the object-oriented paradigm. Also, classes are used extensively as well as private fields and private methods for strong encapsulation. Still, over the course of the book, the domain-related implementations transition towards a more functional style. Also, certain infrastructural functionalities apply selected principles of it wherever useful. As the changes come naturally together with introducing specific concepts, there is no need for upfront knowledge in Functional Programming.
Author(s): Alex Lawrence
Publisher: leanpub.com
Year: 2021
Language: English
Pages: 503
Title Page
Table of Contents
Preface
Chapter 1: Domains
Chapter 2: Domain Models
Chapter 3: Bounded Contexts
Chapter 4: Software Architecture
Chapter 5: Code quality
Chapter 6: Value Objects, Entities and Services
Chapter 7: Domain Events
Chapter 8: Aggregates
Chapter 9: Repositories
Chapter 10: Application Services
Chapter 11: Command Query Responsibility Segregation
Chapter 12: Event Sourcing
Chapter 13: Separate executable programs
Chapter 14: User Interface
Conclusion
Appendix A: Static types
Appendix B: Going into production
Bibliography