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,026 | Comments: 44,842

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.


No future posts left, oh my!


  1. Technical observations from my wife (3):
    13 Nov 2015 - Production issues
  2. Production postmortem (13):
    13 Nov 2015 - The case of the “it is slow on that machine (only)”
  3. Speaking (5):
    09 Nov 2015 - Community talk in Kiev, Ukraine–What does it take to be a good developer
  4. Find the bug (5):
    11 Sep 2015 - The concurrent memory buster
  5. Buffer allocation strategies (3):
    09 Sep 2015 - Bad usage patterns
View all series


Main feed Feed Stats
Comments feed   Comments Feed Stats