Dev Thoughts

Musings from my development journey.

Topics

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

large

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.

Boundaries

  • 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

app/domains/somefeature/somefile1.rb
app/domains/somefeature/somefile2.rb
app/domains/somefeature/somef_file_controller.rb

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.

Publisher

  • 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
E615b4bfacff4ad801a9aa409d4f17af
Why don't you comment your code?
Comment posted by Anthony over 1 year ago
6f560065e46f26926e606868731ea15c
def Initilize() puts "Test" end
Comment posted by Soner about 1 year ago
6f560065e46f26926e606868731ea15c
puts '123'
Comment posted by Soner about 1 year ago