Setting the scene - Layered Architecture

14 02 2008

Domain Driven Design is all about capturing the business logic into application code, no matter how complex it is. But code is not about business logic alone, there needs to be some code to take care of several other aspects like interfacing, data retrieval and persistence, communication, logging, security and much more…

Layered ArchitectureTo ensure that your business logic implementation becomes as maintainable as possible, it should not be influenced by any of the other code. To achieve this, you should separate it from the other aspects using a Layered Architecture.

An example of such a layered application can be found in the picture on the right. Note that layering is only a logical separation of your application and as such it is represented in the solution using solution folders which contain all the assemblies that belong to one logical layer.

The recommended approach for a layered solution is to start of with 4 different layers:

  • Domain layer : Central to the solution should be the domain layer which contains all the business logic for the problem domain at hand. Ensure that this layer is not influenced by any of the other layers.
  • Resource layer : The resource layer supports the application by ensuring that the domain layer gets constructed from any resources at hand, this could be done from a local persistence store like a database or an xml file, or it could be reconstructed from a remote location like a remote service.
  • Interface layer : The interface layer takes care of displaying information from the domain model in the form requested by the consumer. This could be a windows form, a web site, a web service or a wcf data contract depending on the nature of the consumer which could be a human or another service.
  • Application layer : The application layer has the responsibility to coordinate the execution of tasks for the consumer. When the consumer is another service, this layer is rather redundant. But when a human is involved, a lot of state needs to be maintained so that the user gets presented all the reference data she can use to determine her choices before calling into the domain layer.

Special note: When you read the Domain Driven Design book, you will notice that there is no such thing as a resource layer in there. Instead it’s called the infrastructure layer which contains both resource access as other kinds of infrastructure like logging etc… But my experience has learned that you want your infrastructure code out of the way as much as possible, preferably all infrastructure should be invisible in your application using techniques like aspect oriented programming, dependency injection and such. Therefore I recommend to separate all infrastructure code outside your solution into a framework, but leave the resource access in.

Next time we will start the discussion on domain modelling and how to ensure it stays maintainable even when it becomes pretty complex.

See you next time,
Yves Goeleven


Actions

Information

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>



Spiritual Well Being. Part 2


…continued In the text healing wise there is an interesting story to demonstrate this point about a midwife who when thanked profusely for her assistance in birthing states, “I’m there to help her remember HER power; not to display mine. I am there to support HER to deliver the baby; I don’t deliver. …The more invisible [..]


Spiritual Well Being. Part 1


So often we seperate physical well being and spiritual well being; yet aren’t they one and the same? Here are some ponderings on the inherent wisdom found in the teachings of Susun Weed. In my life there have been a few that stood out to me in this special way. Not so much because they were [..]


The Forgotten Muscles


We all know how to work most of our muscles, but what about the ones that most people forget. Kegel exercises can make for an easier pregnancy and spice up your sex life. You can lift weights or run to work your biceps and calves, but what about the forgotten muscles — the ones in the [..]


Rejuvenate your Health with Colon Cleansing and Detoxification


One of the most beneficial immune-rejuvenating habits you can establish for yourself is a periodic intestinal cleanse and liver detoxification. Many health practicioners believe that the change of season is a good time for such cleanses, since our immune systems are often more susceptible to pathogens at these times. A complete cleansing program will address both [..]


How To Get Started In Skateboarding


Learn how to select the right board for you. It looks very cool on the X Games and Gravity Games and it doesn’t cost a lot to get started. So, what is the first thing you need? A skateboard. You can pick up a skateboard at flea markets, yard sales, discount stores, online, and lots of [..]


All News