Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


A Pure Object-oriented Domain Model by a DB Guy, Part 2 : Page 4

This is the second in a new series of articles by Jimmy Nilsson on a new architecture for enterprise applications in .NET. The new architecture is purely object- oriented, while still focusing on roundtrips and the data access code to get good performance. This articles delves into the most important base class for the new architecture.

A Main Design Goal
A main design goal is to keep it simple for the packages to the left. If you take a look at Figure 5, you will see what I mean by to the left.

Figure 5 Overview of the new architecture

What I mean is that it’s important to expose consumers to as simple an interface as possible. Just following a few protocols when writing the classes in the persistence layer is better than the client programmer having to follow a lot. .

A good example of this is where the Persistence layer has to deal with the IPersistable interface for instantiating EntityBase subclasses, while consumers don’t have to think about it at all when they create new instances. Consumers just use New().

Having said that, let’s now discuss the subclasses a little. Once again, I will only discuss them briefly today and go into more detail in future articles.

Delving into an Entity Subclass
So far, we have discussed some of the general features of the new architecture. Now I’d like to investigate how to use the base class. In Figure 6 you can see a subclass (Customer) to EntityBase.

Figure 6 An example of a subclass to EntityBase

To implement the Customer class, I actually don’t need any private fields at all. What I do need is to define an enum for each property to be exposed, as well as some constants for setting offsets in an Object array that the EntityBase class takes care of. So, all fields that Customer exposes as properties are stored in an Object array. That array is very small for unexpanded objects, but grows when the objects are expanded. (This is not only to deal with more properties, but also to deal with both old and current values.) That was a very quick and condensed explanation of some of the inner workings of the EntityBase class. I will have to focus more on this in a future article.

I also have to write some code for each property. However, I have generalized it quite a bit to avoid code bloat. In Listing 1 you can see an example of a property implementation in the Customer class.

Public Property Name() As String

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date