29
.
04
.
2024
11
.
07
.
2022
Ruby on Rails
Domain-Driven Design
Backend
Tutorial

Introduction to DDD in Ruby on Rails

Paweł Strzałkowski
Chief Technology Officer

As a Ruby on Rails community, we have been immune to the changes in the programming world around us for a long time. As if nothing new has been introduced since the beginning of times (or the release of the first version of RoR in 2005). Whereas important and interesting innovations occur all around.

In 2003, Eric Evans released a book titled "Domain-Driven Design: Tackling Complexity in the Heart of Software" which has changed the landscape of many programming technologies. The ideas and techniques promoted by this book are well known among Java, C# or PHP programmers. The approach is used to build better and more reliable software. Especially at the enterprise level, where the attention to detail is at its peak.

Eric Evans wasn't the only person responsible for the global DDD boom. His initial book is often referred to as "The Blue Book", but there is also "The Red Book" or in fact "Implementing Domain-Driven Design" by Vaughn Vernon. These two figures, alongside others who grew out of the Smalltalk community, have driven the programming world into the realm of DDD.

What is Domain-Driven Design?

There are two layers in which it can be described:

  • strategic
  • tactical

Strategic DDD explains how to prepare and maintain a project. Its goal is to characterize parts of the system as Bounded Contexts, refine the terminology using Ubiquitous Language and illustrate the relationships using Context Maps. It is about gathering business expectations and needs. It shows how important it is to communicate doubts and questions back to the management. Finally, it is about IT working hand-in-hand with business to achieve a common goal.

Tactical DDD is a set of techniques used to construct a precise, coherent and useful model of the domain. It defines a set of building blocks such as Entities, Value Objects or Aggregates. It describes how to use Repositories and Factories to maintain the design and its implementation clean and well-defined.

Can DDD be used with Ruby on Rails?

Yes!

On the strategic level, you don't think about a framework or a programming language. Doman-Driven Design helps you to focus on the correct context. It teaches what kind of vocabulary to use and how to approach the architectural decisions.

On the tactical level, Domain-Driven shows that RoR doesn't have to be all about procedural services, quickly becoming god objects. It teaches how to describe your domain in a thought-out and flexible manner. It guides towards decoupled modules and consistent data.

How to start with DDD in Ruby on Rails

There is no one-way. I can only share mine. One thing you SHOULD NOT do at first is jumping right into The Blue Book. It may be too complicated without some initial preparation.

I've started by absorbing materials from various conferences and talks. I've been listening to DDD meetups and related podcasts. I've used recorded talks and high-level articles. When I felt ready, I ordered books by Evans and Vernon and started reading. What came to me as quite a shock was that I really got into them. I was so eager to know more that for the first time it didn't feel like reading "yet another programming book". It was like discovering a new world.

You have to find your own way. But believe me - it's worth it!

At first, it may be hard to incorporate DDD theory into such a conservative framework as Ruby on Rails. Luckily, you will find many examples in the upcoming blog posts within this series. You will also learn how to incorporate them into your projects.

Further Reading

Below, you can find a list of articles published in the DDD in Ruby on Rails series. Each encapsulates a portion of knowledge from tactical or strategic Domain-Driven Design. They are not ordered, but it may be easiest to read them in the listed sequence.

If you would like to first check if the topic is interesting to you, please check out the recording of or DDD webinars.

Domain-Driven Design Visuality Webinars

Resources

Articles in this series

Do you want to know more? Register for our DDD webinar

Paweł Strzałkowski
Chief Technology Officer

Check my Twitter

Check my Linkedin

Did you like it? 

Sign up To VIsuality newsletter

READ ALSO

Writing Chrome Extensions Is (probably) Easier Than You Think

14
.
11
.
2023
Antoni Smoliński
Tutorial
Frontend
Backend

Bounded Context - DDD in Ruby on Rails

17
.
03
.
2024
Paweł Strzałkowski
Ruby on Rails
Domain-Driven Design
Backend
Tutorial

The origin of Poltrax development - story of POLTRAX (part 2)

29
.
11
.
2023
Stanisław Zawadzki
Ruby on Rails
Startups
Business
Backend

Ruby Meetups in 2022 - Summary

14
.
11
.
2023
Michał Łęcicki
Ruby on Rails
Visuality
Conferences

Repository - DDD in Ruby on Rails

17
.
03
.
2024
Paweł Strzałkowski
Ruby on Rails
Domain-Driven Design
Backend
Tutorial

Example Application - DDD in Ruby on Rails

17
.
03
.
2024
Paweł Strzałkowski
Ruby on Rails
Domain-Driven Design
Backend
Tutorial

How to launch a successful startup - story of POLTRAX (part 1)

14
.
11
.
2023
Michał Piórkowski
Ruby on Rails
Startups
Business

How to use different git emails for different projects

14
.
11
.
2023
Michał Łęcicki
Backend
Tutorial

Aggregate - DDD in Ruby on Rails

17
.
03
.
2024
Paweł Strzałkowski
Ruby on Rails
Domain-Driven Design
Backend
Tutorial

Visuality at wroc_love.rb 2022: It's back and it's good!

14
.
11
.
2023
Patryk Ptasiński
Ruby on Rails
Conferences
Ruby

Our journey to Event Storming

14
.
11
.
2023
Michał Łęcicki
Visuality
Event Storming

Should I use Active Record Callbacks?

14
.
11
.
2023
Mateusz Woźniczka
Ruby on Rails
Backend
Tutorial

How to rescue a transaction to roll back changes?

17
.
03
.
2024
Paweł Strzałkowski
Ruby on Rails
Backend
Ruby
Tutorial

Safe navigation operator '&.' vs '.try' in Rails

14
.
11
.
2023
Mateusz Woźniczka
Ruby on Rails
Backend
Ruby
Tutorial

What does the ||= operator actually mean in Ruby?

14
.
11
.
2023
Mateusz Woźniczka
Ruby on Rails
Backend
Ruby
Tutorial

How to design an entity - DDD in Ruby on Rails

17
.
03
.
2024
Paweł Strzałkowski
Ruby on Rails
Domain-Driven Design
Backend
Tutorial

Entity - DDD in Ruby on Rails

17
.
03
.
2024
Paweł Strzałkowski
Ruby on Rails
Domain-Driven Design
Backend
Tutorial

Should I use instance variables in Rails views?

14
.
11
.
2023
Mateusz Woźniczka
Ruby on Rails
Frontend
Backend
Tutorial

Data Quality in Ruby on Rails

14
.
11
.
2023
Michał Łęcicki
Ruby on Rails
Backend
Software

We started using Event Storming. Here’s why!

14
.
11
.
2023
Mariusz Kozieł
Event Storming
Visuality

First Miłośnicy Ruby Warsaw Meetup

14
.
11
.
2023
Michał Łęcicki
Conferences
Visuality

Should I use Action Filters?

14
.
11
.
2023
Mateusz Woźniczka
Ruby on Rails
Backend
Tutorial

Value Object - DDD in Ruby on Rails

17
.
03
.
2024
Paweł Strzałkowski
Ruby on Rails
Domain-Driven Design
Backend
Tutorial