Ompluscator's Blog
  • Home
  • All Articles
  • Golang
  • Tools

ddd

September 18, 2023

Practical DDD in Golang: Specification

Use cases of the versatile Specification pattern include validation, creation, and querying.

There are not many code structures that bring me joy whenever I need to write them. The first time I implemented such code was with a lightweight ORM in Go, back when we didn’t have one. However, I used ORM for many years, and at some point, when you rely on ORM, using QueryBuilder becomes inevitable. Here, you may notice terms like “predicates”, and that’s where we can find the Specification pattern.
September 18, 2023

Practical DDD in Golang: Repository

Implementing the Anti-Corruption layer using a well-known DDD pattern: Repository.

Today, it is hard to imagine writing an application without accessing some form of storage at runtime. This includes not only writing application code but also deployment scripts, which often need to access configuration files, which are also a type of storage in a sense. When developing applications to solve real-world business problems, connecting to databases, external APIs, caching systems, or other forms of storage is practically unavoidable. It’s no surprise, then, that Domain-Driven Design (DDD) includes patterns like the Repository pattern to address these needs.
September 18, 2023

Practical DDD in Golang: Factory

The story about Domain-Driven Design (DDD) continues by introducing a legendary pattern: the Factory.

When I wrote the title of this article, I was trying to remember the first design pattern I had learned from “The Gang of Four”. I think it was one of the following: Factory Method, Singleton, or Decorator. I am sure that other software engineers have a similar story. When they started learning design patterns, either Factory Method or Abstract Factory was one of the first three they encountered. Today, any derivative of the Factory pattern is essential in Domain-Driven Design, and its purpose remains the same, even after many decades.
🍺 Support my Blogging work

Join the Ompluscator's Blog Community

Hey there! Want to be part of our awesome community? Just drop your email below, and we'll send you the good stuff – cool articles, fun updates, and more. No spam, we promise!

Thank you for subscribing!

September 18, 2023

Practical DDD in Golang: Aggregate

One DDD pattern to rule them all.

I have spent years understanding and practicing the DDD approach. Most of the principles were easy to understand and implement in the code. However, there was one that particularly caught my attention. I must say that the Aggregate pattern is the most critical one in DDD, and perhaps the entire Tactical Domain-Driven Design doesn’t make sense without it. It serves to bind business logic together. While reading, you might think that the Aggregate resembles a cluster of patterns, but that is a misconception.
September 17, 2023

Practical DDD in Golang: Module

The discussion about DDD in Go now leads us to explore a cluster of highly cohesive structures known as Modules.

At first glance, Modules may not seem like a typical software development pattern, especially when we often associate patterns with specific code structures or behaviors. This can be particularly confusing when considering Go Modules. These modules consist of closely related Go Packages, are versioned, and released together, serving as a form of dependency management in Go. Since both Go Modules and Packages impact the project’s structure, it raises the question of their relationship with the DDD pattern known as Module.
September 17, 2023

Practical DDD in Golang: Domain Event

The tale of DDD in Go advances by introducing a fundamental building block that mirrors real-world events — the Domain Event.

In many cases, Entities are the most effective means of representing elements in Domain-Driven Design. Together with Value Objects, they can provide a precise reflection of our Problem Domain. However, sometimes, the most apt way to depict a Problem Domain is by employing events that transpire within it. In my experience, I increasingly attempt to identify events and then discern the Entities associated with them. Although Eric Evans didn’t cover the Domain Event pattern in the first edition of his book, today, it’s challenging to fully develop the domain layer without incorporating events.
September 17, 2023

Practical DDD in Golang: Domain Service

The story of DDD in Go continues by introducing one of the stateless building blocks - the Domain Service.

After discussing Entity and Value Objects, I will now introduce the third member of the group of Domain-Modeling patterns in this article: Domain Service. Domain Service is perhaps the most misunderstood DDD pattern, with confusion stemming from various web frameworks. In many frameworks, a Service takes on a multitude of roles. It’s responsible for managing business logic, creating UI components such as form fields, handling sessions and HTTP requests, and sometimes even serving as a catch-all “utils” class or housing code that could belong to the simplest Value Object.
September 17, 2023

Practical DDD in Golang: Entity

The story about DDD in Go continues by introducing one of the most common building blocks — the Entity.

In the previous article, I attempted to provide insights into the Value Object design pattern and how we should apply it in Go. In this article, the narrative continues with the introduction of a design pattern called Entity. Many developers have heard about Entity countless times, even if they’ve never used the DDD approach. Examples can be found in PHP frameworks and Java. However, its role in DDD differs from its use elsewhere.
September 16, 2023

Practical DDD in Golang: Value Object

Let's begin a practical journey into Domain-Driven Design in Golang, starting with the most important pattern: Value Objects.

Saying that a particular pattern is the most important might seem like an exaggeration, but I wouldn’t even argue against it. The first time I encountered the concept of a Value Object was in Martin Fowler’s book. At that time, it seemed quite simple and not very interesting. The next time I read about it was in Eric Evans’ “The Big Blue Book.” At that point, the pattern started to make more and more sense, and soon enough, I couldn’t imagine writing my code without incorporating Value Objects extensively.
© Ompluscator's Blog 2024
  • Cookie Policy
  • Privacy Policy
  • Terms and Conditions
  • Consent Preferences

${title}

${content}