𝔖 Scriptorium
✦   LIBER   ✦

πŸ“

Designing Hexagonal Architecture with Java: Build maintainable and long-lasting applications with Java and Quarkus [Team-IRA]

✍ Scribed by Davi Vieira


Publisher
2
Year
2023
Tongue
English
Leaves
438
Category
Library

⬇  Acquire This Volume

No coin nor oath required. For personal study only.

✦ Synopsis


Learn to build robust, resilient, and highly maintainable cloud-native Java applications with hexagonal architecture and Quarkus

Key Features

  • Use hexagonal architecture to increase maintainability and reduce technical debt
  • Learn how to build systems that are easy to change and understand
  • Leverage Quarkus to create modern cloud-native applications
  • Purchase of the print or Kindle book includes a free PDF eBook

Book Description

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 book explores how the hexagonal architecture can help build robust, change-tolerable, maintainable, and cloud-native applications that can meet the needs of enterprises seeking to increase their profits while dealing with uncertainties. This book starts by uncovering the secrets of the 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 with ports and use cases in the application hexagon, and make your software compatible with different technologies by employing adapters in the framework hexagon. In this new edition, you’ll learn about the differences between a hexagonal and layered architecture and how to apply SOLID principles while developing a hexagonal system based on a real-world scenario. Finally, you’ll get to grips with using Quarkus to turn your hexagonal application into a cloud-native system.

By the end of this book, you’ll be able to develop robust, flexible, and maintainable systems that will stand the test of time.

What you will learn

  • Apply SOLID principles to the hexagonal architecture
  • Assemble business rules algorithms using the specified design pattern
  • Combine domain-driven design techniques with hexagonal principles to create powerful domain models
  • Employ adapters to enable system compatibility with various 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 software component isolation
  • 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 looking to improve code maintainability and enhance productivity with an architecture that allows changes in technology without compromising business logic. 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 Uses 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. Comparing Hexagonal Architecture with Layered Architecture

(N.B. Please use the Look Inside option to see further chapters)

✦ Table of Contents


Cover
Preface
Part 1:Architecture Fundamentals
Chapter 1: Why Hexagonal Architecture?
Technical requirements
Reviewing software architecture
Making decisions
The invisible things
Technical debt
Vicious cycle
It’s not for everyone
Monolithic or distributed
Understanding hexagonal architecture
Domain hexagon
Application hexagon
Use cases
Output ports
Framework hexagon
Advantages of the hexagonal approach
Summary
Questions
Further reading
Answers
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
Using value objects to compose entities
Assuring consistency with aggregates
Modeling an aggregate
Working with domain services
Using policy and specification to deal with business rules
Creating specifications
Creating policies
Defining business rules as POJOs
Summary
Questions
Further reading
Answers
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
Answers
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
Answers
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
Creating the Add Network page
Creating the Get Router page
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
Answers
Part 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
The 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
Answers
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
Answers
Chapter 8: Building the Framework Hexagon
Technical requirements
Bootstrapping the Framework hexagon
Implementing output adapters
The router management output adapter
The switch management output adapter
Implementing the input adapters
The router management input adapter
The switch management input adapter
The network management input adapter
Testing the Framework hexagon
Summary
Questions
Answers
Chapter 9: Applying Dependency Inversion with Java Modules
Technical requirements
Introducing the 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
Answers
Further reading
Part 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
Answers
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
Answers
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
Answers
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
Answers
Part 4:Hexagonal Architecture and Beyond
Chapter 15: Comparing Hexagonal Architecture with Layered Architecture
Technical requirements
Reviewing the layered architecture
Creating an application using the layered architecture
Implementing the data layer
Implementing the service layer
Implementing the API layer
Testing the layered application
Refactoring a layered architecture application into a hexagonal one
Implementing the Domain hexagon
Implementing the Application hexagon
Implementing the Framework hexagon
Testing the hexagonal application
Assessing the benefits and disadvantages of hexagonal and layered architectures
Summary
Questions
Answers
Chapter 16: Using SOLID Principles with Hexagonal Architecture
Technical requirements
Understanding SOLID Principles
Single Responsibility Principle (SRP)
Open-Closed Principle (OCP)
Liskov Substitution Principle (LSP)
Interface Segregation Principle (ISP)
Dependency Inversion Principle (DIP)
Applying SOLID on a hexagonal architecture system
Applying the SRP
Applying the OCP
Applying the LSP
Applying the ISP
Applying the DIP
Exploring other design patterns
Singleton
Builder
Abstract factory
Summary
Questions
Answers
Chapter 17: 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 for creating ports and use cases
Dealing with multiple adapter categories
Conclusion – the hexagonal journey
Summary
Questions
Answers
Index
Other Books You May Enjoy


πŸ“œ 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

<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 πŸ› 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 Cloud-Native Applications with
✍ Francesco Marchioni; Mark Little πŸ“‚ Library πŸ“… 2019 πŸ› Packt Publishing 🌐 English

<p><b>Build robust and reliable Java applications that works on modern infrastructure, such as containers and cloud, using the new features in Quarkus 1.0</b></p> Key Features <li>Build apps with faster boot time and low RSS memory using the latest Quarkus 1.0 features </li> <li>Seamlessly integrate

Service Oriented Architecture with Java:
✍ Binildas A. Christudas, Malhar Barai, Vincenzo Caselli πŸ“‚ Library πŸ“… 2008 πŸ› Packt Publishing 🌐 English

This book shows how to use SOA and web services to build powerful applications in Java. It teaches the concepts and the implementation with best-practice real-world examples. You will learn to design a sound architecture for successful implementation of any business solution, the different types of