0%

Book Description

Gain insight into how hexagonal architecture can help to keep the cost of development low over the complete lifetime of an application

Key Features

  • Explore ways to make your software flexible, extensible, and adaptable
  • Learn new concepts that you can easily blend with your own software development style
  • Develop the mindset of building maintainable solutions instead of taking shortcuts

Book Description

We would all like to build software architecture that yields adaptable and flexible software with low development costs. But, unreasonable deadlines and shortcuts make it very hard to create such an architecture.

Get Your Hands Dirty on Clean Architecture starts with a discussion about the conventional layered architecture style and its disadvantages. It also talks about the advantages of the domain-centric architecture styles of Robert C. Martin's Clean Architecture and Alistair Cockburn's Hexagonal Architecture. Then, the book dives into hands-on chapters that show you how to manifest a hexagonal architecture in actual code. You'll learn in detail about different mapping strategies between the layers of a hexagonal architecture and see how to assemble the architecture elements into an application. The later chapters demonstrate how to enforce architecture boundaries. You'll also learn what shortcuts produce what types of technical debt and how, sometimes, it is a good idea to willingly take on those debts.

After reading this book, you'll have all the knowledge you need to create applications using the hexagonal architecture style of web development.

What you will learn

  • Identify potential shortcomings of using a layered architecture
  • Apply methods to enforce architecture boundaries
  • Find out how potential shortcuts can affect the software architecture
  • Produce arguments for when to use which style of architecture
  • Structure your code according to the architecture
  • Apply various types of tests that will cover each element of the architecture

Who this book is for

This book is for you if you care about the architecture of the software you are building. To get the most out of this book, you must have some experience with web development. The code examples in this book are in Java. If you are not a Java programmer but can read object-oriented code in other languages, you will be fine. In the few places where Java or framework specifics are needed, they are thoroughly explained.

Table of Contents

  1. Preface
    1. About the Book
      1. About the Author
      2. Learning Objectives
      3. Audience
      4. Approach
      5. Conventions
      6. Feedback
  2. Chapter 1
  3. What's Wrong with Layers?
    1. It Promotes Database-Driven Design
    2. It's Prone to Shortcuts
    3. It Grows Hard to Test
    4. It Hides the Use Cases
    5. It Makes Parallel Work Difficult
    6. How Does This Help Me Build Maintainable Software?
  4. Chapter 2
  5. Inverting Dependencies
    1. The Single Responsibility Principle
    2. A Tale about Side Effects
    3. The Dependency Inversion Principle
    4. Clean Architecture
    5. Hexagonal Architecture
    6. How Does This Help Me Build Maintainable Software?
  6. Chapter 3
  7. Organizing Code
    1. Organizing by Layer
    2. Organizing by Feature
    3. An Architecturally Expressive Package Structure
    4. The Role of Dependency Injection
    5. How Does This Help Me Build Maintainable Software?
  8. Chapter 4
  9. Implementing a Use Case
    1. Implementing the Domain Model
    2. A Use Case in a Nutshell
    3. Validating Input
    4. The Power of Constructors
    5. Different Input Models for Different Use Cases
    6. Validating Business Rules
    7. Rich versus Anemic Domain Model
    8. Different Output Models for Different Use Cases
    9. What about Read-Only Use Cases?
    10. How Does This Help Me Build Maintainable Software?
  10. Chapter 5
  11. Implementing a Web Adapter
    1. Dependency Inversion
    2. Responsibilities of a Web Adapter
    3. Slicing Controllers
    4. How Does This Help Me Build Maintainable Software?
  12. Chapter 6
  13. Implementing a Persistence Adapter
    1. Dependency Inversion
    2. The Responsibilities of a Persistence Adapter
    3. Slicing Port Interfaces
    4. Slicing Persistence Adapters
    5. Example with Spring Data JPA
    6. What about Database Transactions?
    7. How Does This Help Me Build Maintainable Software?
  14. Chapter 7
  15. Testing Architecture Elements
    1. The Test Pyramid
    2. Testing a Domain Entity with Unit Tests
    3. Testing a Use Case with Unit Tests
    4. Testing a Web Adapter with Integration Tests
    5. Testing a Persistence Adapter with Integration Tests
    6. Testing Main Paths with System Tests
    7. How Much Testing is Enough?
    8. How Does This Help Me Build Maintainable Software?
  16. Chapter 8
  17. Mapping Between Boundaries
    1. The "No Mapping" Strategy
    2. The "Two-Way" Mapping Strategy
    3. The "Full" Mapping Strategy
    4. The "One-Way" Mapping Strategy
    5. When to Use Which Mapping Strategy?
    6. How Does This Help Me Build Maintainable Software?
  18. Chapter 9
  19. Assembling the Application
    1. Why Even Care about Assembly?
    2. Assembling via Plain Code
    3. Assembling via Spring's Classpath Scanning
    4. Assembling via Spring's Java Config
    5. How Does This Help Me Build Maintainable Software?
  20. Chapter 10
  21. Enforcing Architecture Boundaries
    1. Boundaries and Dependencies
    2. Visibility Modifiers
    3. Post-Compile Checks
    4. Build Artifacts
    5. How Does This Help Me Build Maintainable Software?
  22. Chapter 11
  23. Taking Shortcuts Consciously
    1. Why Shortcuts Are Like Broken Windows
    2. The Responsibility of Starting Clean
    3. Sharing Models between Use Cases
    4. Using Domain Entities as Input or Output Models
    5. Skipping Incoming Ports
    6. Skipping Application Services
    7. How Does This Help Me Build Maintainable Software?
  24. Chapter 12
  25. Deciding on an Architecture Style
    1. The Domain is King
    2. Experience is Queen
    3. It Depends
18.190.217.134