All Projects → paulrayner → Ddd_sample_app_ruby

paulrayner / Ddd_sample_app_ruby

Licence: mit
Idiomatic Ruby port of the DDD sample application

Programming Languages

ruby
36898 projects - #4 most used programming language

== Ruby DDD Sample App

=== Goal

The goal of this sample app is to provide an idiomatic Ruby port of the DDD sample application. It should remain faithful to the intention of the purposes of the original DDD sample application.

=== Why a Ruby port?

Because Paul wanted to learn Ruby and see how well it supports DDD. Also, interested in questions like:

  • How does the choice of Ruby affect the implementation of the DDD building block patterns?
  • How well does an opinionated MVC framework like Rails support doing DDD?
  • What are implications of choosing a document store like MongoDB for aggregate design and eventual consistency?

=== Why a DDD Sample App?

  1. Provide a how-to example for implementing a typical DDD application
  • Descriptive, not prescriptive
  • Idiomatic
  • Update sample app with latest ideas
  1. Support discussion of implementation practices
  • Engage Ruby community in dialog and learning about DDD
  • Show design and implementation tradeoffs
  • Teach DDD (tend to be Java & .NET) community more about Ruby
  1. Lab mouse for controlled experiments
  • Learn Ruby as a language and ecosystem
  • Can Rails + MongoDB carry the weight of a complex domain model?
  • Tradeoffs between Sinatra vs Rails for Ruby web apps

=== Problems with Sample Apps

=== DDD Sample Application

History

The .NET port is being used as the primary basis for this Ruby port.

== Implementation Stack

  • Persistence: MongoDB
  • Data access: Mongoid-backed repositories
  • Domain model: Plain Ruby objects
  • UI: Rails stack (w/ Twitter bootstrap)
  • Aggregate eventual consistency: Wisper-async leveraging Celluloid
  • GOAL: Before DDDx London - June 14 DONE!

_The focus of this version is to see how implementing a domain model within Rails affects the implementation.

== Aggregates

The aggregate roots are:

  • Cargo
  • HandlingEvent
  • Location
  • Voyage

== Design Decisions

Here you'll find information on design choices made, and the relative tradeoffs. Plus resources for further reading. Actually, mostly resources right now.

=== Value Objects

==== Immutability in Ruby

==== Libraries/Gems Supporting Immutability in Ruby

=== Enums in Ruby

=== Equality in Ruby

== Persistence

=== MongoDB

==== Mongo ORMs

=== Repository Pattern in Ruby

Have not yet found a repository implementation that supports aggregates. Rather, each implementation follows a repository-per-object approach, which is not what we need.

There is an on issue for Curator regarding https://github.com/braintree/curator/issues/16[ supporting foreign keys and embedded objects], and some experimentation in a branch with adding a https://github.com/braintree/curator/commit/repository_mapping[mapping API] which may do what I need.

https://github.com/ifesdjeen/entrepot[Entrepot] looks promising. It uses Virtus for the objects and has this kinda weird approach of referencing a repository from a repository:

[source, ruby]

class Address include Virtus include Entrepot::Model

attribute :street, String attribute :city, String attribute :country, String end

class Person include Virtus include Entrepot::Mongo::Model

attribute :name, String attribute :address, Address end

class PersonRepository include Entrepot::Repository

has_many :articles, :repository => :ArticleRepository end

=== Aggregates

==== Concurrency in Ruby

==== Eventual Consistency

Resources for implementing eventual consistency (i.e. performing asynchronous updates) between aggregate instances.

===== Worker Queues

===== Messaging

===== Celluloid

=== DDD and Rails

== Contributing

This is a learning experiment, pull requests are welcome! Bonus points for feature branches.

To get started, see https://github.com/paulrayner/ddd_sample_app_ruby/issues?state=open[milestones and issues]. Use the https://github.com/SzymonPobiega/DDDSample.Net[vanilla .NET port version] as the basis for any work.

Progress and learning will be shared after the DDD Exchange on June 14 through posts on http://thepaulrayner.com[Paul Rayner's blog].

== Copyright

Copyright (C) 2013 Paul Rayner. See link:LICENSE[LICENSE] for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].