Setting the scene - Divide and conquer

17 03 2008

Last time we discussed the concept of model driven design, and introduced a miniature domain model representing a Business Partner. Yet in real world applications, domain models aren’t that simple, in fact they tend to become pretty unwieldy if not extremely large. As the business domain that we are trying to capture is rather complex, it seems logical that the domain model is complex as well. Still, the practice of Domain Driven Design is trying to tackle the complexity at the heart of the matter. To prevent from having dependencies all over the place, it’s recommended to divide your domain model into distinct parts with little or no coupling between the parts, these parts are called modules. Modules should be named after business terms, in fact if the name of the module isn’t part of the Ubiquitous Language, you probably started of on the wrong foot. Even though modules are designed to reduce coupling between business concepts, dependencies are allowed, but only in one direction. It’s perfectly normal that one part of your business domain depends on another part of the same domain.

I like to represent modules with folders containing classes in the domain. In the future though I hope we can have a nice DSL that displays the domain layer with all modules as simple shapes in a domain diagram, implemented behind the scenes as folders, and that allows to drill down to the components that are contained in the module. The different types of components that can exist in a module will be discussed in upcoming articles, for now we will continue with a real life example of how to determine modules.

gasflowmanagement.jpg To determine modules one should simply look at the business domain. Currently I’m working on a contracting application for the belgian gas flow manager, so the domain is definitly contracting. Now if you think about contracts, you probably think about different Business Partners signing Agreements right? Business partners can take up different roles depending on the agreement that is signed, they could be shippers, traders, gas flow managers etc. Furthermore agreements can come in many forms: first of all there is the master agreement that says that we’re going to do business together, next we have technical agreements that limit for example the pressure of gas that is exchanged or the rules that apply for allocation of capacity to the buyer and there are many more of these kinds of agreements. But just signing a paper isn’t going to cut it! If you want to, for example, store gas, you have to make sure whether it is possible or we may blow up that nice little storage tank. So you have to ask whether you can get a certain Service at a given point or period in time, services could for example consist of rights to store gas, or to inject it, to trade it, etc…

Now if you look at the description above of a typical contracting domain for the gas flow market, one can identify a few big groups of business logic in there. These big groups, like in this example Business Partners, Agreements and Services, are what modules are all about. Note that there is a direct dependency from Services to Agreements to Business Partners, but not the other way around.

To wrap up, if your domain is rather complex ( and which one isn’t? ), split it up in different parts based on the knowledge that you have of the particular domain, but be sure to let the domain be your guide.

Next time we will start to go through the different components that can be found inside a module.

Stay tuned,
Yves Goeleven


Actions

Information

2 responses to “Setting the scene - Divide and conquer”

19 03 2008
Steve Degosserie (09:25:02) :

Nice article Yves … what about mapping a module to an assembly instead of a directory ?

Pushing the idea further, an assembly being the container for a module, your module becomes a self-contained & re-usable functional unit of work. As a free feature, assembly references will enforce the constraint of one-way relation between your modules.

Eventually, your Domain Model is composed of several ‘mini-functional frameworks’ that can be re-used accros projects of a customer.

19 03 2008
Goeleven Yves (13:31:54) :

Steve,

We used to do that at my current customer, but we stepped away from the approach because we ended up with too many projects in a typical solution, which caused visual studio to perform badly. But if you plan to have only a handful of modules, it will indeed be a valid approach.

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>



Short Changed l


You’re in the waiting room on a Monday morning, its 20 minutes past your 10:30 a.m. appointment and you’re getting a little testy. You’ve skimmed People magazine and now you’re looking at the floral prints on the walls. The same prints you’ve been forced to look at when you’re on time and your doctor is [..]


Nutrition For Your Sight: Better Vision Through Better Nutrition


Each day gets dimmer. Each night turns darker. Each decade looks fuzzier. Is it old age? Is it reading in the dark? Or, Is it just bad nutrition? Read further for the top vision preserving nutrients. How many times has your optometrist asked you about your diet? Often, nutrition is an overlooked solution to future eye [..]


Circuit Training for a Change of Pace


Try circuit training to get or keep you fit when you’re short of workout time. Circuit training consists of going quickly from one exercise to another for an extended period of time, say 20 minutes. It is promoted as giving both strength and aerobic training in the same workout. It does that, but you compromise both. [..]


Decreasing the Incidence of Work-Related Back Injury


Many of us spend many a long hour each day sitting at a desk and working on a computer. Do you sit in the right position? Think about how you sit. It’s common that the longer you sit, the more you will find that you are slumping in the chair. This causes the bottom of [..]


Leave Men Alone


Some men should not be left alone. Not because we don’t trust them. Not because they can’t find anything when you are gone. There is another reason. If you do, what happens is this: bad things happen. At least, this is what my wonderful husband says when I go off on a plane somewhere. He’s not the [..]


All News