Ayende @ Rahien

My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:


+972 52-548-6969

, @ Q c

Posts: 6,125 | Comments: 45,492

filter by tags archive

Limit your abstractionsSo what is the whole big deal about?

time to read 3 min | 453 words

When I started out, I pointed out that I truly dislike this type of architecture:


And I said that I much rather an architecture that has a far more limited set of abstractions, and I gave this example:

  1. Controllers
  3. Entities
  4. Commands
  5. Tasks
  6. Events
  7. Queries

That is all nice in theory, but let us talk in practice, shall we? How do we actually write code that actually uses this model?

Let us show some code that uses this type of code, this type, this is from the C# port of the same codebase, available here.

public class CargoAdminController : BaseController
  public ActionResult Register(
      [ModelBinder(typeof (RegistrationCommandBinder))] RegistrationCommand registrationCommand)
      DateTime arrivalDeadlineDateTime = DateTime.ParseExact(registrationCommand.ArrivalDeadline, RegisterDateFormat,

      string trackingId = BookingServiceFacade.BookNewCargo(
          registrationCommand.OriginUnlocode, registrationCommand.DestinationUnlocode, arrivalDeadlineDateTime

      return RedirectToAction(ShowActionName, new RouteValueDictionary(new {trackingId}));

Does this looks good to you? Here is what is actually going on here.


You can click on this link look at what is going in here (and I removed some stuff for clarity’s sake.

This stuff is complex, more to the point, it doesn’t read naturally, it is hard to make a change without modifying a lot of code. This is scary.

We have a lot of abstractions here, services and repositories and facades and what not. (Mind, each of those thing is an independent abstraction, not a common one.)

In my next post, I’ll show how to refactor this to a much saner model.

More posts in "Limit your abstractions" series:

  1. (22 Feb 2012) And how do you handle testing?
  2. (21 Feb 2012) The key is in the infrastructure…
  3. (20 Feb 2012) Refactoring toward reduced abstractions
  4. (16 Feb 2012) So what is the whole big deal about?
  5. (15 Feb 2012) All cookies looks the same to the cookie cutter
  6. (14 Feb 2012) Commands vs. Tasks, did you forget the workflow?
  7. (13 Feb 2012) You only get six to a dozen in the entire app
  8. (10 Feb 2012) Application Events–event processing and RX
  9. (09 Feb 2012) Application Events–Proposed Solution #2–Cohesion
  10. (07 Feb 2012) Application Events–Proposed Solution #1
  11. (06 Feb 2012) Application Events–what about change?
  12. (03 Feb 2012) Application Events–the wrong way
  13. (02 Feb 2012) Analyzing a DDD application



FYI When I click on the diagram, I only see a small copy. Too small to read.

Ayende Rahien


Neil Mosafi

Ahh lol me being a dumbass


When I click the picture, it's the same size...

Mads Laumann

Uhhh, a cliffhanger :)

Looking forward to see the refactored version.

Mohamed RAHIM

Is this a REVIEW (Rebuttal) of the DDD Abstractions (Introduced By Eric Evans)? Or only a REVIEW of the Cargo specific DDD Sample?


The code at the controller level looks pretty reasonable.... But that call graph is fucking absurd.


I think most of this code is domain code. And this code is unrelated to service or facade itself. Only thing I see, that can simplyfy it is to divide method in BookingService into smaller parts.


What program did you use to generate that sequence diagram?

Harry Steinhilber

@Dan - it looks like the sequence diagram generated by Visual Studio Ultimate (right click on a method and select Generate Sequence Diagram).


I have been reading your apporoach since a while now also i reviewed effectus source code but im always wondering can this apporoach be used with webforms and how can you do it (the problem with the life cycle no controllers as boundary) ? i hope i will get an answer thank you in advance

Ayende Rahien

Arcan, You can use similar approach, sure. You can look at how Rhino Igloo was implemented for some ideas on structuring things in WebForms world.


Thank you i have been thinking to use webforms mvp specially the message bus and publish subscribe that it use to communicate between different presenters or may be i will adapt it to fit my needs :) thank you again

Comment preview

Comments have been closed on this topic.


  1. RavenDB 3.5 whirl wind tour: I'll have the 3+1 goodies to go, please - 3 days from now
  2. The design of RavenDB 4.0: Voron has a one track mind - 4 days from now
  3. RavenDB 3.5 whirl wind tour: Digging deep into the internals - 5 days from now
  4. The design of RavenDB 4.0: Separation of indexes and documents - 6 days from now
  5. RavenDB 3.5 whirl wind tour: Deeper insights to indexing - 7 days from now

And 10 more posts are pending...

There are posts all the way to May 30, 2016


  1. The design of RavenDB 4.0 (14):
    05 May 2016 - Physically segregating collections
  2. RavenDB 3.5 whirl wind tour (14):
    04 May 2016 - I’ll find who is taking my I/O bandwidth and they SHALL pay
  3. Tasks for the new comer (2):
    15 Apr 2016 - Quartz.NET with RavenDB
  4. Code through the looking glass (5):
    18 Mar 2016 - And a linear search to rule them
  5. Find the bug (8):
    29 Feb 2016 - When you can't rely on your own identity
View all series


Main feed Feed Stats
Comments feed   Comments Feed Stats