Let's build components, not layers by Tom Hombergs @ Spring I/O 2022

Conference: Spring I/O 2022

Year: 2022

Spring I/O 2022 - Barcelona, 26-27 May Slides: https://speakerdeck.com/thombergs/lets-build-components-not-layers Code is written once and read often. So we should focus on making it easily readable. We all know that. The same is true for the architecture of an application. It’s usually created once and then read and re-read, understood and misunderstood, interpreted and misinterpreted a lot of times by a lot of people during its lifetime. We try to get a grip on this problem by using architectural patterns like layers. While layers are a well-understood structure, they only help in understanding the big picture of the application’s architecture. They usually don’t do a good job of organizing the code into pieces that are easy to understand and reason about. Usually, a better approach to structure the code is to build components. Like lego bricks, we can compose multiple (vertical and horizontal) components to a bigger component, until we have built a complete application. We can zoom in and out of the codebase along the seams of the components to understand what we need to understand at the level of abstraction that we are currently concerned with. In this talk, we’ll explore a lightweight way of structuring the codebase of a Spring Boot application that will feel like building lego. This component-based structure is easy to understand and reason about. It’s also easy to maintain over time thanks to a single rule that can be enforced by tooling. Java, Spring Boot, and ArchUnit bring all the tools we need for a nice component-based codebase, we just need to use them. ================================================ Video Chapters 00:00:00 Introduction 00:04:50 About the speaker 00:05:50 Why organise code? 00:08:47 What's wrong with layers? 00:12:09 What's wrong with vertical slices? 00:14:36 Clean / Hexagonal architecture 00:21:38 Component-based architecture 00:30:58 Field Study - Building a check engine component 00:43:44 Why build components? 00:47:03 Thank you