Making Good Software

A blog by Alberto G (Alberto Gutierrez)

Written by Alberto Gutierrez

May 17th, 2010 at 4:57 pm

How to create a good domain model. Top 10 advices

with 5 comments

Domain modeling is the most important part of software design. Having a good model allows developers and business to have a common language, which in turn, makes much simpler the communication of requirements and the maintenance of the application.

Having a good model is synonym of having a low representational gap. Having a low representational gap means that the main concepts and their relationships from the real business model are represented almost identically in the software domain model.

Creating a good domain model is one of the most difficult challenges developers have to face. What follows are some advices to create a good domain model

1.- Understand the business model completely.

In order to create a good domain model, developers need to look into the detail of the the business model, not only in the surface. It requires to understand and distill the main entities and then find their closest equivalent software abstractions.

2.- Use good names for all your domain model classes.

Naming is critical in software domain modeling. There are two qualities that you should be looking for in a good name for an entity in your model:

  • Consistent. Business and developers should always use the same term to define a single concept.
  • Exact. A name should exactly define the responsibilities of an entity in the domain model.

3.- Use metaphors.

Many times is necessary to model abstract operations/entities in software development, (processing orders, simulations…), for these cases, metaphors will help you to simplify the design of the domain model.

4.- Make the domain model self-contained.

The domain model should contain the raw logic of the application. Any additional logic should be contained in some other layers, as for instance the work-flow, dependency injection, persistence…

5.- Make the domain model independent.

The domain model shouldn’t change because the underlying persistence implementation or the UI or any other layer changes.

6.- Make the domain model technically simple.

It should only contain POJOs. The responsibilities assigned to an entity in the domain model should be limited to only those necessary for the software domain

7.- Keep the domain model updated.

Synchronize it always with the business domain model, having two unsynchronized models is one of the biggest sources of productivity killers. Synchronization requires refactoring and enough test coverage to make sure that things don’t break as they are refactored.

8.- Make the software domain model match the business domain model.

A software domain model should be easy to understand for a business domain model expert and it shouldn’t have any discrepancy.

9.- Care for the code quality of your domain model.

There are two reasons why you want to make sure that the code quality of the domain model is top-notch.

  • The domain model is the foundation of your application, if it is bad, the whole thing can fall apart
  • It changes a lot. There are very few areas in your code that are going to change so many times as the domain model

10.- Test the domain model independently, and involve the customer in the test.

As already mentioned, the domain model is an independent and very important part of the architecture of the application. That’s why is so important to pay attention to test it in isolation. Involving the customers in this test phase can be very productive as they can identify test cases that are likely in production and which probably are the most interesting ones to test.

5 Responses to 'How to create a good domain model. Top 10 advices'

Subscribe to comments with RSS or TrackBack to 'How to create a good domain model. Top 10 advices'.

  1. It sounds like you are a proponent of a “rich” domain model. It is commendable that you see the benefits of an object oriented design in a language that was designed to be object oriented.

    But in practice, I have never seen a satisfactory implementation of this. Inevitably, myriad compromises need to be made for persistence, the object life-cycle and other services that don’t quite fit the model.

    If you have had success with this technique, I’d love to see more blog posts on the subject.

    Daniel Alexiuc

    17 May 10 at 6:28 pm

  2. Hi Daniel!

    Thanks for your comment. I am actually surprise that you have never seen a satisfactory domain model implementation, in my opinion is the base for any good application. I would like to believe that in the projects I have worked in, we have been successful creating a good enough Domain Model, I’ll try to post more articles about this subject.

    Alberto Gutierrez

    18 May 10 at 2:27 am

  3. Far and away the best methodology for developing a domain model is UML Modeling in Color. See Peter Coad’s book Java Modeling in Color with UML for more information. You can’t go wrong if you use this approach.

    Phil

    19 May 10 at 4:37 am

  4. Hi Phil!

    Thanks for your insights, I’m going to add the book you mention in my Amazon wish list.

    Alberto Gutierrez

    19 May 10 at 8:35 am

  5. […] 5 SEO Tactics That Make You Look Like a Douche Agile makes me SMART What Is Great Software? How to create a good domain model. Top 10 advices 5 Nontraditional Ways To Improve WordPress SEO Asshole driven development Usability Testing: […]

Leave a Reply