Tuesday, September 21

Layered Architecture vs Living Domain Model

Update: Fowler has blogged about this.

I just finished a great talk with Jon Tirsen, basically he points out that a layered architecture can get between you and your domain model.

We were discussing that the "small talk way" (i.e. the OO way) is to have a rich, living, useful domain model that does all the interesting things in your application.

If you have a layered architecture, you can end up having a service layer that seperates your client code (view or action) from your domain model.

Jon pointed out that having one of these layers, when you dont need one, is like burning $50 notes. You end up writing hundreds of lines of code in your service layer including marshalling and unmarshalling across the boundaries.

Another bad effect is that teams often end up implementing functionality as transaction scripts rather than in the domain where it belongs. The more you do this, the more anemic your domain model becomes, and the less useful your domain language becomes for solving problems in the future.

The advice from all this is that the one kind of appliction that does NOT need a layered architecture is a web application. Your views can and should have a rich and close collaboration with your domain code.

This conversation really got me thinking, is it actually possible to maintain a living domain model with a service layer in the way?

14 Comments:

Blogger Ben Hogan said...

Jon sent me this comment: "[Doing it this way] you still have a layered architecture, ie: Operating System/Database/Web Server/Application/Browser. It's just that [the other way] it's layered in the wrong way, you create a distribution boundary in the middle of your app! where you don't need it. "

3:52 pm  
Anonymous Anonymous said...

"is it actually possible to maintain a living domain model with a service layer in the way?"

Sure, a remote interface is not an excuse to neglect your domain model. You have to take special care to relegate you service logic to a thin facade over your domain layer that does nothing but adapt your domain model to the remote interface (i.e. no business logic).

2:06 am  
Anonymous Anonymous said...

Hi,

I am working on a new design pattern for my Bachelors thesis project. I would be grateful if you read this and let me know your views:

Distributed Command Pattern - an extension of command pattern for connected systems

http://www.codeproject.com/csharp/DistributedCommandPattern.asp

7:48 am  
Blogger Admin said...

Great blog, keep up the good work. Glad to see sites like this.

Here is another good site I said I would pass along.
Domain Names
Thanks

6:50 am  
Blogger The Answer Man said...

Real Estate Investors......You Are Shortchanging Yourself If You Are Just Doing "Fix And Flips", Foreclosures Or Renting

Properties.

Let Me Explain Why......

Click Here For More Information




Income Property

6:23 am  
Anonymous Christian Catchpole said...

you create a distribution boundary in the middle of your app! where you don't need it.

This is the exact problem I have come across recently. A system using J2EE facades to split business and display layers. Hibernate objects which would normally load on demand, now must be fully pre-loaded before moving to the display tier.

The tier boundary is just an extra expense, especially when the business layer doesn't do too much, computationally. Quicker to leave it all in the one tier and use techniques such as Hibernate clustering to maintain state across the server array.

I guess what I'm saying is that a server array need not be a fully-fledged tier array.

12:08 pm  
Blogger The Computer Guys said...

Yo, you have a Terrific blog here! Lots of content means more readers, more readers means more interaction!
I'm definitely going to bookmark you!
I have a
window xpsite/blog. It pretty much covers window xp related stuff.
Come take a Look when you get a chance. :-)

12:43 pm  
Anonymous Anonymous said...

This is a good post. I have a site about orlando real estate please look at it if you can.

6:50 pm  
Blogger The Computer Guys said...

Yo, you have a Terrific blog here! Lots of content means more readers, more readers means more Sales!
I'm definitely going to bookmark you!
I have a window xp sp1window xp sp1 site/blog. It pretty much covers window xp sp1 Problems with your Windows Xp Computing !
Come and check it out if you get time We are just a Click Away ! :-)

2:05 pm  
Anonymous Anonymous said...

If you are looking to change the look of your emails from plain white with black text to a colorful, eye-catching, attention grabbing email, OnLetterhead is the product for you. Go from "White" to "Wow" with one click!

With "OnLetterhead's "Ease of Send & Setup" (EOSS) technology, all the work is done before you type your message! Just click and send and see the results a branded difference can make.
**Marketing Strategies for the Future**

2:59 pm  
Anonymous Anonymous said...

Nice Site. We have Free Houses on my site. Please take a look home construction

7:46 pm  
Blogger The Computer Guys said...

Hey, you have a great blog here! I'm definitely going to bookmark you!
I have a windows xp fasterwindows xp faster site/blog. It pretty much covers windows xp faster Problems with your Windows Xp Computing !
Come and check it out if you get time :-)

3:09 pm  
Anonymous Anonymous said...

Great Blog you have here!
I'm definitely going to bookmark this one.
Do you know DOT WS (website) will be larger than DOT COM (commercial) ?
Remember 800 phone numbers? Now you have 888 877 etc.
Are you a visionary? I hope you are and decide to get in on something
that will change your life! GDI is where its at.
7 day free trial and no selling
Want a short .WS domain name? Now you can get one and make affiliate $$$$$$$
You get your own website
Check this one out :-)domain saledomain sale

9:24 pm  
Blogger jessn said...

Great blog!

Jon really has some good points here, I strongly agree with him.

I have earlier had a discussion with an architure dept. They insist in the many layered approach - maybe they will realize that I'm right now...

I have published a few articles about security and software architectures as well. They can be found at http://jessn.blogspot.com/

8:44 am  

Post a Comment

Links to this post:

Create a Link

<< Home