Architecture vs. Infrastructure

This is my first post on Neo (.NET Entity Objects), a framework for .NET developers who want to write enterprise applications with an object-based domain model. I have been using Neo for little over a year now, and it has suited me perfectly for my .NET ORM needs. To further quote the website:

Neo includes tools that create an extensible object-based domain model as well as the database schema from a an abstract description of the model. At runtime, rich schema information is used to dynamically generate all SQL required for object persistence management. Being based on ADO.NET data sets, a Neo domain model is independent of the actual backing store and works equally well with databases and objects in an XML representation.

One of the nicest features features of Neo is that it encourages you to place the business logic in the domain objects. As developers, we have been thought good object-oriented practices such as data abstraction, information hiding, encapsulation, inheritance, polymorphism. It almost seems that we forgot about these principles when we started to make Enterprise software: in both J2EE land and .NET, I often see the following architecture:

  1. Data layer, which contains value objects with just properties,
  2. Business or service layer, with Manager or Service classes that manipulate the data objects
  3. Presentation layer, which calls the business layer

This not a object-oriented architecture (which combines data and process together), this is a functional architecture. Why should we give up on our OO-practices? Because we want to store something in a database? Shouldn’t that be just a matter of serialization…

As counter-argument, I am often told that enterprise-like features such as security, transactions, or auditing cannot be implemented when using a behavioral domain model. Thus, what you see is that the infrastructure of the project is often more important than the architecture; it seeps through the design. Martin Fowler calls this the Anemic Domain Model anti-pattern.

I think that this is wrong: the infrastructure should be a thin layer on top of the architecture, and never influence it. And to end this post on topic: Neo nudges you in the right direction: for every entity, it generates two classes: a value-containing base class, and a behavioral subclass that you are supposed to edit.

4 Comments

  1. Paul Gielens said,

    March 16, 2005 @ 7:40

    Interesting pov, one with which I mostly agree. I was wondering what your thoughts are on supporting POCO (like Mats NPersist http://www.npersist.com/home/Default.aspx) in Neo.

  2. Arjen said,

    March 16, 2005 @ 9:55

    POCOs are definately on the radar, though at the moment, I cannot say if and how we are going to implement them.

    However, inheriting from a base class like the EntityObject also has its advantages. For instance, there is always an ObjectContext available for you to use.

  3. The Ancient Art of Programming » Spring and the Behavioral Domain Model said,

    May 14, 2005 @ 0:18

    […] ent of a behavioral domain model. I wrote about the advantages of a behavioral domain in a previous post, but since that post was about .NET, I’ll […]

  4. Jim Goodman said,

    June 4, 2005 @ 12:02

    I tried NEO two years ago. I found it clunky and couldn’t understand how it’s an object-relational tool. It doesn’t support inheritence, and the way it handles many-to-many relationships is a total cop out. We had to munge our domain model to suit the limitations of the tool, which surely defeats the object (if you’ll excuse the pun!) It generated all the code into a single file, which took ages and sometimes didn’t work at all. Trying to evolve our domain model in a test-driven way was seriously difficult. It was a major pain to work with, and we threw it out after 3 weeks and decided to hand-roll our persistence layer - which worked out much cheaper in the long run, and resulted in a domain model that actually matched the analysis model. Since then, I’ve used NHibernate, which was a dream in comparison - though i’m keen to find out what the new WinFS implementation looks like for ObjectSpaces. With much better competition out there, and even better on the way, maybe the developers should just bin NEO?

RSS feed for comments on this post