๐”– Scriptorium
โœฆ   LIBER   โœฆ

๐Ÿ“

Designing Hexagonal Architecture with Java: An architect's guide to building maintainable and change-tolerant applications with Java and Quarkus

โœ Scribed by Davi Vieira


Publisher
Packt Publishing
Year
2022
Tongue
English
Leaves
460
Category
Library

โฌ‡  Acquire This Volume

No coin nor oath required. For personal study only.

โœฆ Synopsis


A practical guide for software architects and Java developers to build cloud-native hexagonal applications using Java and Quarkus to create systems that are easier to refactor, scale, and maintain

Key Features

  • Learn techniques to decouple business and technology code in an application
  • Apply hexagonal architecture principles to produce more organized, coherent, and maintainable software
  • Minimize technical debts and tackle complexities derived from multiple teams dealing with the same code base

Book Description

Hexagonal architecture enhances developers' productivity by decoupling business code from technology code, making the software more change-tolerant, and allowing it to evolve and incorporate new technologies without the need for significant refactoring. By adhering to hexagonal principles, you can structure your software in a way that reduces the effort required to understand and maintain the code.

This book starts with an in-depth analysis of hexagonal architecture's building blocks, such as entities, use cases, ports, and adapters. You'll learn how to assemble business code in the Domain hexagon, create features by using ports and use cases in the Application hexagon, and make your software compatible with different technologies by employing adapters in the Framework hexagon. Moving on, you'll get your hands dirty developing a system based on a real-world scenario applying all the hexagonal architecture's building blocks. By creating a hexagonal system, you'll also understand how you can use Java modules to reinforce dependency inversion and ensure the isolation of each hexagon in the architecture. Finally, you'll get to grips with using Quarkus to turn your hexagonal application into a cloud-native system.

By the end of this hexagonal architecture book, you'll be able to bring order and sanity to the development of complex and long-lasting applications.

What you will learn

  • Find out how to assemble business rules algorithms using the specification design pattern
  • Combine domain-driven design techniques with hexagonal principles to create powerful domain models
  • Employ adapters to make the system support different protocols such as REST, gRPC, and WebSocket
  • Create a module and package structure based on hexagonal principles
  • Use Java modules to enforce dependency inversion and ensure isolation between software components
  • Implement Quarkus DI to manage the life cycle of input and output ports

Who this book is for

This book is for software architects and Java developers who want to improve code maintainability and enhance productivity with an architecture that allows changes in technology without compromising business logic, which is precisely what hexagonal architecture does. Intermediate knowledge of the Java programming language and familiarity with Jakarta EE will help you to get the most out of this book.

Table of Contents

  1. Why Hexagonal Architecture?
  2. Wrapping Business Rules inside Domain Hexagon
  3. Handling Behavior with Ports and Use Cases
  4. Creating Adapters to Interact with the Outside World
  5. Exploring the Nature of Driving and Driven Operations
  6. Building the Domain Hexagon
  7. Building the Application Hexagon
  8. Building the Framework Hexagon
  9. Applying Dependency Inversion with Java Modules
  10. Adding Quarkus to a Modularized Hexagonal Application
  11. Leveraging CDI Beans to Manage Ports and Use Cases
  12. Using RESTEasy Reactive to Implement Input Adapters
  13. Persisting Data with Output Adapters and Hibernate Reactive
  14. Setting Up Dockerfile and Kubernetes Objects for Cloud Deployment
  15. Good Design Practices for Your Hexagonal Application

โœฆ Table of Contents


Cover
Title Page
Copyright and credits
Contributors
About the author
About the reviewer
Table of Contents
Preface
Section 1: Architecture Fundamentals
Chapter 1: Why Hexagonal Architecture?
Technical requirements
Reviewing software architecture
The invisible things
Vicious cycle
It's not for everyone
Monolithic or distributed
Making decisions
Understanding the hexagonal architecture
Domain hexagon
Application hexagon
Framework hexagon
Advantages of the hexagonal approach
Summary
Questions
Further reading
Chapter 2: Wrapping Business Rules inside Domain Hexagon
Technical requirements
Modeling a problem domain with entities
The purity of domain entities
Relevant entities
Using UUIDs to define identity
Enhancing descriptiveness with value objects
Assuring consistency with aggregates
Working with domain services
Using policy and specification to deal with business rules
Defining business rules as POJOs
Summary
Questions
Further reading
Chapter 3: Handling Behavior with Ports and Use Cases
Technical requirements
Expressing software behavior with use cases
How to create a use case
Implementing use cases with input ports
Using output ports to deal with external data
It's not only about repositories
Where to use output ports
Automating behavior with the Application hexagon
Summary
Questions
Further reading
Chapter 4: Creating Adapters to Interact with the Outside World
Technical requirements
Understanding adapters
Using input adapters to allow driving operations
Creating input adapters
Using output adapters to speak with different data sources
Creating output adapters
Summary
Questions
Further reading
Chapter 5: Exploring the Nature of Driving and Driven Operations
Technical requirements
Reaching the hexagonal application with driving operations
Integrating web applications with the hexagonal system
Running test agents
Calling the hexagonal system from other applications
Handling external resources with driven operations
Data persistence
Messaging and events
Mock servers
Summary
Questions
Section 2: Using Hexagons to Create a Solid Foundation
Chapter 6: Building the Domain Hexagon
Technical requirements
Bootstrapping the Domain hexagon
Understanding the problem domain
Defining value objects
Defining entities and specifications
The Equipment and Router abstract entities
Core router entity and its specifications
Edge router entity and its specifications
Switch entity and its specifications
Defining domain services
Router service
Switch service
Network service
Testing the Domain hexagon
Summary
Questions
Chapter 7: Building the Application Hexagon
Technical requirements
Bootstrapping the Application hexagon
Defining use cases
Creating written descriptions for router management use cases
Defining the use case interface for router management
Creating written descriptions for switch management use cases
Defining the use case interface for switch management
Creating written descriptions for network management use cases
Defining the use case interface for network management
Implementing use cases with input ports
Testing the Application hexagon
Summary
Questions
Chapter 8: Building the Framework Hexagon
Technical requirements
Bootstrapping the Framework hexagon
Implementing output adapters
Router management output adapter
Switch management output adapter
Implementing input adapters
Router management input adapter
Switch management input adapter
Network management input adapter
Testing the Framework hexagon
Summary
Questions
Chapter 9: Applying Dependency Inversion with Java Modules
Technical requirements
Introducing JPMS
Inverting dependencies on a hexagonal application
Providing services with use cases and input ports
Providing services with output ports and output adapters
Making the input adapters dependent on abstractions
Using the Java platform's ServiceLoader class to retrieve JPMS provider implementations
Initializing RouterManagementGenericAdapter
Initializing SwitchManagementGenericAdapter
Initializing NetworkManagementGenericAdapter
Summary
Questions
Further reading
Section 3: Becoming Cloud-Native
Chapter 10: Adding Quarkus to a Modularized Hexagonal Application
Technical requirements
Revisiting the JVM
Speeding up runtime performance with JIT compilation
Improving startup time with AOT compilation
Introducing Quarkus
Creating REST endpoints with JAX-RS
Employing dependency injection with Quarkus DI
Validating objects
Configuring a data source and using Hibernate ORM
Adding Quarkus to a modularized hexagonal application
Summary
Questions
Chapter 11: Leveraging CDI Beans to Manage Ports and Use Cases
Technical requirements
Learning about Quarkus DI
Working with beans
Transforming ports, use cases, and adapters into CDI beans
Implementing CDI for router management objects
Implementing CDI for switch management objects
Implementing CDI for network management classes and interfaces
Testing use cases with Quarkus and Cucumber
Summary
Questions
Answers
Chapter 12: Using RESTEasy Reactive to Implement Input Adapters
Technical requirements
Exploring the approaches to handling server's requests
Imperative
Reactive
Implementing input adapters with RESTEasy Reactive
Implementing the Reactive input adapter for router management
Implementing the Reactive input adapter for switch management
Implementing the Reactive input adapter for network management
Adding OpenAPI and Swagger UI
Testing Reactive input adapters
Summary
Questions
Chapter 13: Persisting Data with Output Adapters and Hibernate Reactive
Technical requirements
Introducing Hibernate Reactive and Panache
Hibernate Reactive features
Panache features
Enabling reactive behavior on output adapters
Configuring reactive data sources
Configuring entities
Implementing reactive repository classes
Implementing reactive output adapters
Reactive router management of the MySQL output adapter
Reactive switch management of the MySQL output adapter
Testing the reactive output adapters
Summary
Questions
Chapter 14: Setting Up Dockerfile and Kubernetes Objects for Cloud Deployment
Technical requirements
Preparing the Docker image
Creating a Docker image with an Uber .jar artifact
Creating a Docker image with a native executable
Creating Kubernetes objects
Reviewing Kubernetes main objects
Configuring Kubernetes objects for the hexagonal system
Deploying on Minikube
Summary
Questions
Chapter 15: Good Design Practices for Your Hexagonal Application
Technical requirements
Using Domain Driven Design to shape the Domain hexagon
Understanding the business we are in
Promoting collaboration to increase knowledge
Applying DDD techniques to build the Domain hexagon
Implementing bounded contexts and subdomains in a hexagonal system
The need to create ports and use cases
Dealing with multiple adapter categories
Conclusion โ€“ the hexagonal journey
Summary
Questions
Assessments
Other Books You May Enjoy
Index


๐Ÿ“œ SIMILAR VOLUMES


Designing Hexagonal Architecture with Ja
โœ Davi Vieira ๐Ÿ“‚ Library ๐Ÿ“… 2022 ๐Ÿ› Packt Publishing ๐ŸŒ English

<p><b>A practical guide for software architects and Java developers to build cloud-native hexagonal applications using Java and Quarkus to create systems that are easier to refactor, scale, and maintain</b></p><h4>Key Features</h4><ul><li>Learn techniques to decouple business and technology code in

Designing Hexagonal Architecture with Ja
โœ Davi Vieira ๐Ÿ“‚ Library ๐Ÿ“… 2022 ๐Ÿ› Packt Publishing ๐ŸŒ English

Code <p><b>A practical guide for software architects and Java developers to build cloud-native hexagonal applications using Java and Quarkus to create systems that are easier to refactor, scale, and maintain</b></p><h4>Key Features</h4><ul><li>Learn techniques to decouple business and technology co

Designing Hexagonal Architecture with Ja
โœ Davi Vieira ๐Ÿ“‚ Library ๐Ÿ“… 2023 ๐Ÿ› 2 ๐ŸŒ English

<p><span>Learn to build robust, resilient, and highly maintainable cloud-native Java applications with hexagonal architecture and Quarkus</span></p><h4><span>Key Features</span></h4><ul><li><span><span>Use hexagonal architecture to increase maintainability and reduce technical debt</span></span></li

Designing Hexagonal Architecture with Ja
โœ Davi Vieira ๐Ÿ“‚ Library ๐Ÿ“… 2023 ๐Ÿ› Packt Publishing Limited ๐ŸŒ English

We live in a fast-evolving world with new technologies emerging every day, where enterprises are constantly changing in an unending quest to be more profitable. So, the question arises โ€” how to develop software capable of handling a high level of unpredictability. With this question in mind, this bo

Hands-On Software Architecture with Java
โœ Giuseppe Bonocore ๐Ÿ“‚ Library ๐Ÿ“… 2022 ๐Ÿ› Packt ๐ŸŒ English

Key Features ------------ Understand the fundamentals of software architecture and build production-grade applications in Java Make smart architectural decisions with comprehensive coverage of various architectural approaches from SOA to microservices Gain an in-depth understanding of deploy