
Domain-Driven Refactoring
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
- Gain hands-on experience in applying strategic and tactical patterns through real-world examples
- Transform your architecture with practical guidance for seamless refactoring
- Purchase of the print or Kindle book includes a free PDF eBook
Book DescriptionAs software development continues to grow, mastering domain-driven design (DDD) will help transform your approach to complex systems. Filled with actionable insights and practical examples, this book is your essential guide to implementing DDD principles, covering its key concepts and practical applications in modern architecture. Alessandro, an eCommerce specialist and DDD expert with 30 years of experience, and Alberto, a dedicated backend developer, tap into their extensive expertise to help you refactor your monolith into a modular structure, whether it be evolving into microservices or enhancing a maintainable monolith, resulting in a system that adapts to changing business needs and non-functional requirements. You'll explore vital DDD patterns like strategic design with bounded contexts and ubiquitous language, improving communication between technical and domain experts. The chapters take you through modeling techniques to manage complexity and increase flexibility, while also addressing microservices integration, including inter-service communication, transaction management, and data strategies. By the end of this book, you'll be able to decompose a monolith and refine its architecture for adaptability, all while ensuring business logic remains central to your software design and development.What you will learn - Find out how to recognize the boundaries of your system's components
- Apply strategic patterns such as bounded contexts and ubiquitous language
- Master tactical patterns for building aggregates and entities
- Discover principal refactoring patterns and learn how to implement them
- Identify pain points in a complex code base and address them
- Explore event-driven architectures for component decoupling
- Get skilled at writing tests that validate and maintain architectural integrity
Who this book is forThis book is ideal for software developers, architects, and team leads looking to modernize legacy applications using domain-driven design principles. If you're a backend developer or software engineer looking to enhance your understanding of DDD, this guide will elevate your skills in designing robust systems. Team leads and architects will find valuable insights for guiding their teams through the transition from monoliths to microservices. Familiarity with C# is a must, as the book provides practical examples in this language.
All prices
More details
Content
Preface
The software development domain is constantly evolving, driven by the increasing demands of businesses and the growing complexity of technological ecosystems. Applications must now adapt to distributed architectures, support rapid changes, and remain resilient under immense pressure-all while aligning closely with business goals. These challenges are both exciting and daunting, requiring developers and architects to think beyond code and embrace methodologies that bridge the gap between technical precision and business alignment.
Modern software development operates at a crossroads where business innovation and technical challenges intersect. As organizations grow and adapt, the demands on software systems build up. Legacy architectures, once sufficient for simpler times, often struggle to keep pace with the agility and scalability required today. Distributed systems have become the norm, promising flexibility but introducing their own challenges, such as eventual consistency, fault tolerance, and coordination across services. In such an environment, it is easy to lose sight of the domain-the heart of the problem the software aims to solve.
This is where Domain-Driven Design (DDD) steps in. Since its introduction by Eric Evans in 2003, DDD has served as a transformative approach for designing software systems that reflect the intricacies of real-world domains. The approach offers strategies for modeling complexity, structuring applications, and enabling effective collaboration between technical and business teams. This book is our contribution to the rich ecosystem of DDD knowledge, aiming to guide you through the principles, patterns, and practices that make DDD not just a philosophy but a practical toolset for modern software development.
Who this book is for
Whether you are a software developer, architect, or team lead, this book is crafted to enhance your ability to build systems that are robust, scalable, and aligned with the business they support. Specifically, this book is for the following people:
- Developers who want to move beyond coding and understand how to design systems that solve real-world problems effectively
- Architects tasked with creating modular, maintainable, and scalable solutions in increasingly complex environments
- Technical leaders who seek to foster collaboration between cross-functional teams and ensure that technical decisions support business goals
No matter your role, if you're passionate about creating software that not only works but thrives under complexity, this book is for you.
What this book covers
Chapter 1, Evolution of Domain-Driven Design, introduces the origins of DDD, tracing its development from early software engineering practices to its current role in addressing complexity. This chapter explores the fundamental challenges that DDD aims to solve and provides an overview of its key principles, including ubiquitous language and bounded contexts.
Chapter 2, Understanding Complexity: Problem and Solution Space, dives into the nature of complexity in software systems and teaches you how to distinguish between essential and accidental complexity. This chapter introduces tools such as the Cynefin framework and EventStorming, equipping you to navigate problem and solution spaces effectively.
Chapter 3, Strategic Patterns, covers the strategic aspects of DDD, focusing on dividing domains into bounded contexts and defining clear relationships between them. This chapter teaches you how to apply techniques such as context mapping and how to create a ubiquitous language that fosters collaboration and reduces ambiguity.
Chapter 4, Tactical Patterns, provides an overview of the tactical building blocks of DDD, such as entities, value objects, aggregates, repositories, and domain services, with practical examples of implementing these patterns in code while maintaining alignment with business rules.
Chapter 5, Introducing Refactoring Principles, teaches you how to identify and address technical debt in legacy systems using DDD principles. This chapter introduces key refactoring strategies, emphasizing the importance of modularity and incremental change to improve the maintainability and scalability supported by various kinds of tests.
Chapter 6, Transitioning from Chaos, focuses on transforming monolithic systems into modular architectures. This chapter explores practical steps for decoupling tightly coupled services, identifying bounded contexts, and implementing clear interfaces to simplify interactions.
Chapter 7, Integrating Events with CQRS, shows you how to implement Command Query Responsibility Segregation with EventSourcing (CQRS+ES). This chapter explains how to use events to decouple systems, ensure scalability, and maintain consistency while managing eventual consistency challenges.
Chapter 8, Refactoring the Database, provides strategies for aligning database schemas with bounded contexts and refactoring shared tables, as well as introducing patterns such as Expand/Contract. This chapter also covers techniques for handling data consistency in distributed systems.
Chapter 9, DDD Patterns for Continuous Integration and Continuous Refactoring, explores how to integrate DDD with continuous integration and delivery practices. This chapter focuses on automation, iterative design, and maintaining alignment between domain models and technical implementation.
Chapter 10, When and Why You Should Transition to a Microservices Architecture, provides guidance on transitioning from a modular monolith to a microservices architecture. This chapter highlights the trade-offs and complexities of distributed systems and explains how DDD principles can help with this evolution.
Chapter 11, Dealing with Events and Their Evolution, explains how to manage event versioning in event-sourced systems to ensure compatibility and adaptability over time. This chapter introduces strategies such as upcasting, schema evolution, and content negotiation.
Chapter 12, Orchestrating Complexity: Advanced Approaches to Business Processes, explores advanced DDD techniques for managing distributed systems and business processes. Topics covered in this chapter include sagas, choreography versus orchestration, and ensuring system consistency in the face of failures.
To get the most out of this book
This book is designed to be a practical guide for mastering DDD and applying its principles in real-world scenarios. Whether you're new to DDD or have some prior experience, this book provides a structured approach to help you navigate the complexities of modern software development. At the time of writing this book, all the code was tested with .NET 8 running under Docker Desktop for Windows version 4.36.
Software/hardware covered in the book
Operating system requirements
Docker
Windows, macOS, or Linux
C#
Windows, macOS, or Linux
RabbitMQ
Windows, macOS, or Linux
Kurrent (formerly EventStoreDB)
Windows, macOS, or Linux
Download the example code files
The code bundle for the book is hosted on GitHub at https://github.com/PacktPublishing/Domain-driven-Refactoring/branches. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing. Check them out!
Download the color images
We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://packt.link/gbp/9781835885949.
Conventions used
There are a number of text conventions used throughout this book.
CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. For example: "A possible implementation, again using SalesOrderCreated with the added IsReseller property, could be as follows."
A block of code is set as follows:
public class DiscountService { public decimal CalculateDiscount(SalesOrder order) { if (order.Discount == null) { return 0; } var result = //. do...
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.
File format: ePUB
Copy protection: without DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Use a reader that can handle the file format ePUB, such as Adobe Digital Editions or FBReader – both free (see eBook Help).
- Tablet/Smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePUB works well for novels and non-fiction books – i.e., 'flowing' text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook does not use copy protection or Digital Rights Management
For more information, see our eBook Help page.