Get Your Facts Straight: Embrace Event-Driven Architecture for Software Engineering Projects

Anes Hasicic
3 min readOct 6, 2023

In the world of software engineering, the architectural approach one adopts can significantly impact the efficiency and maintainability of a system. One alternative gaining traction is the event-driven architecture, a paradigm that revolves around the concept of events and facts rather than a traditional state-driven approach. Let’s delve into this paradigm shift and understand its potential to revolutionize software development.

The Essence of Event-Driven Architecture

At first glance, you might question whether central event streams are analogous to depending on a central MySQL database. The answer lies in the fundamental principle of event/table entry duality. While MySQL retains the final state of entities, an event-driven approach focuses on immutable facts, representing the true essence of the system. In this model, events are immutable and persisted, while the state remains transient.

In essence, the crucial distinction between state and fact is what sets this approach apart. This distinction holds true, regardless of how the data is accessed or stored, making a central store of facts distinct from a central store of state. Events are presented as a stream of facts, making them highly flexible for interpretation and temporal analysis. Conversely, tables embody the last version of the domain model, making it challenging to extend without touching the state, thus impeding the refactoring process.

Unlocking Flexibility and Evolution

The beauty of event-driven architecture lies in the flexibility it provides to evolve a codebase along various axes. By eliminating a single source of truth for the form of data and embracing a single source of final and historical truth, this approach empowers developers to explore different avenues without fear of disrupting the entire system.

In distributed systems and the era of microservices, where complexities abound, embracing this paradigm becomes paramount. Here are some key takeaways to guide your journey:

Event Storming

Leverage event storming to unveil the emergent behavior and properties of your system. This technique, rooted in business and domain language, helps map explicit facts shaping different workflows within the system.

Mapping the Dark Matter

Address the MA or the dark matter, to resolve the hidden complexities and define the system’s boundaries. Identifying and understanding these components will pave the way for a cohesive architecture.

Event Modeling

Employ event modeling at the system level to explicitly map workflows, discover actors and domain concepts, and understand their meaning in different contexts. Define concepts based on facts, distinguishing between static and dynamic immutable data, and implement them accordingly.

Harnessing the Power of UIs

User interfaces serve as drivers and readers of the system, often spanning multiple contexts in terms of meaning and behavior. However, they don’t need to mirror the domain concepts precisely. Introduce an explicit layer (BFF) to map business concepts to UI concepts, allowing the UI to evolve independently from the backend.

Summary of Building Blocks

To successfully embrace event-driven architecture, keep these building elements in mind:

  • Facts (Domain Events): Immutable events that represent the essence of the system.
  • Bounded Contexts: Clearly defined boundaries that encapsulate specific functionalities and behaviors.
  • Ubiquitous Language and Context-Specific Concepts: Establish a common language and domain-specific concepts for effective communication and understanding.
  • Workflows and Process Managers: Use state (read models), commands, and events to drive behavior within the system.
  • Different Actors and Views: Explicitly define actors and consider different views (UIs and portals) into the system.
  • Aggregation Layers: Implement aggregation layers for each window into the system to ensure decoupling and flexibility.

In closing, the event-driven approach holds immense potential to elevate software engineering by promoting flexibility, maintainability, and meaningful work. By embracing this paradigm, we can move beyond localized optimizations and envision a systemic transformation that streamlines development and maximizes productivity. Let’s strive for a future where every line of code contributes to a purposeful and impactful journey in the world of software.

--

--