Designing Hexagonal Architecture with Java: An architect’s guide to building maintainable and change-tolerant applications with Java and Quarkus
- Length: 460 pages
- Edition: 1
- Language: English
- Publisher: Packt Publishing
- Publication Date: 2022-01-07
- ISBN-10: 1801816484
- ISBN-13: 9781801816489
- Sales Rank: #1789898 (See Top 100 Books)
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.
Designing Hexagonal Architecture with Java and Quarkus: Build change-tolerant software with improved maintainability by applying hexagonal architecture principles 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 Answers 2 Wrapping Business Rules inside Domain Hexagon Technical requirements Modeling the problem domain with entities The purity of domain entities Relevant entities Using UUID 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 POJO Summary Questions Further reading Answers 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 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 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 Answers 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 Answers 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 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 Answers 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 10 Adding Quarkus to a Modularized Hexagonal Application Technical requirements Revisiting the Java Virtual Machine Speeding up runtime performance with JIT compilation Improving start-up 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 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
Donate to keep this site alive
How to download source code?
1. Go to: https://github.com/PacktPublishing
2. In the Find a repository… box, search the book title: Designing Hexagonal Architecture with Java: An architect’s guide to building maintainable and change-tolerant applications with Java and Quarkus
, sometime you may not get the results, please search the main title.
3. Click the book title in the search results.
3. Click Code to download.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.