3

Background: I couldn't find a standard definition for "rich domain model". I may call it non-anemic domain model. So, it could be defined as a software domain model where the domain objects contain little or no intensive business logic (validations, calculations, business rules etc.).

Anemic domain models are widely defined in ERD. But, entity relationship model obviously is not sufficient for rich domain objects. Domain models can be expressed in UML. However, it lacks representation for business logic (constraints, rules, etc.). I've read some articles on OCL describing rules for UML. But, I've never seen any industrial use of it.

Question: Could you suggest any approach for defining rich domain objects? This approach should focus on data, constraints and rules rather than classes and sequences. For example, I don't want to define Student class with enroll method. I want to define Student entity with some enrollment rules. Of course, I could simply define the rules with some comment on code, but I seek a formal method for this.

Edit: I don't expect an answer like "use that tool, it's wonderful". I expect experiences and advises about for example DSL creation, UML profiles, etc.

2
  • Was there something about the definitions you found that you feel like you cannot consolidate them into something that makes sense to you?
    – JeffO
    Commented Sep 6, 2016 at 20:52
  • @JeffO Actually, I haven't found many definitions. General programming languages and UML define business logic implicitly. Definition with human language requires extreme effort for code generation as Euphoric said.
    – Q Q
    Commented Sep 7, 2016 at 6:31

2 Answers 2

1

You can use either "unstructured" or "structured" approach.

Unstructured approach is to use simple human language to define "rules" along something like UML to define structure. This is generally simple to create and understand, but takes considerable effort to turn into executable code.

As for structured approach, there have been many attempts in the past. I would argue none of them really succeed, because sooner or later, you would either fall back to unstructured language. Or move to writing actual code. (related)

That is why for most people, "Rich Domain Model" means "code representing business and domain model".

1

IMHO the most popular approach (at least, currently) to this is Domain Driven Design. I am not a DDD expert, but AFAIK most of the business logic is described by developing a more or less formalized, so called "ubiquitous language".

5
  • Do you know any example of ubiquitous language?
    – Q Q
    Commented Sep 6, 2016 at 12:40
  • As I said, I am not an expert on DDD, though I worked in a project 15 years ago where we did something similar, before the term DDD was even invented. But maybe you can start here: programmers.stackexchange.com/questions/304471/…. But don't expect too much, "ubiquitous language" still refers to human language within the team.
    – Doc Brown
    Commented Sep 6, 2016 at 12:52
  • "I worked in a project 15 years ago where we did something similar, before the term DDD was even invented." – Eric Evans is very vocal about the fact that he didn't actually invent anything new, except the actual name "Domain-Driven Design". He says it's just good OOD, he jus wrote it down and gave it some catchy names. Commented Sep 6, 2016 at 16:15
  • @JörgWMittag: so what?
    – Doc Brown
    Commented Sep 6, 2016 at 16:16
  • there is a framework from apache named ISIS, some time ago they were presenting a rich domain object but it seems they switched to naked object and are oriented in DDD now. I can't even find the old page with the rich objects explanation from old documentation.
    – Walfrat
    Commented Nov 5, 2016 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.