Dev Thoughts

Musings from my development journey.


Built to last: A domain-driven approach to beautiful systems


Talk from Andrew Hao at Rails Conf 2017.

What Makes a System Beautiful?

  • Language: syntax, form, expressiveness
  • Tooling - developer ergonomics
  • Tests - test practices and coverage
  • Longevity - it can stand the test of time with changing business/product requirements

Deconstructing a Monolith

  • Microservices are challenging
  • How much should be extracted?
  • What if I extract something that's too specific? Too generic?

Domain Driven Design

"Domain-driven design (DDD) is an approach to software development for complex needs by connecting the implementation to an evolving model."

Context map

  • Integrating a ubiquitous language
  • Develop a glossary of common terms and standards to follow so all team members are speaking the same language
  • Rename code components to follow the glossary rules

Visualize System

  • Generate an ERD diagram

Core Domain

What the business does that makes it unique.

Supporting Domains

Supporting roles that help to make the core domain happen.

After defining the core and supporting domains, identify them in the ERD diagram.


  • Classes
  • Modules
  • Gems
  • Rails engines
  • Rails app
  • Separate app or API

Bounded Context

  • A running software system (codebase or app)
  • Where concepts live (or are contained)

Bounded context allows us to have concise language.

Overlay bounded contexts

  • Draw lines around system boundaries/bounded contexts
  • View how components are segmented
  • Draw out dependencies based on how the components communicate with each other

The goal: Each domain should have its own bounded context. (aka should be highly cohesive and loosely coupled)

Break Components Into Domains


Removing god objects with Aggregate Root

  • Simplify the outside interfaces
  • Only expose aggregate roots (direct method calls, JSON data, API endpoints)
  • Build a service object that creates the aggregate root. Could be a query, struct, etc.


  • Wisper gem for publishing domains
  • Utilizes command objects

ActiveJob Integration

By leveraging active job, you can have domains communicate with each other via async. You can also integrate tools such as RabbitMQ for managing the message bus.

What's Next?

  • Incrementally migrate features into domains
  • Could migrate domains into microservice components

DD Role

  • Works with large systems
  • Complex domain
  • Large team
  • Outside teams
Why don't you comment your code?
Comment posted by Anthony over 5 years ago
def Initilize() puts "Test" end
Comment posted by Soner over 5 years ago
puts '123'
Comment posted by Soner over 5 years ago