> For the complete documentation index, see [llms.txt](https://hanfak.gitbook.io/workspace/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hanfak.gitbook.io/workspace/general-paradigms/architecture/patterns/domain/domain-model.md).

# Domain Model Pattern

## What is it?

* Using an OO way instead of procedural in transaction pattern
  * objects have state and behaviour
* Build model of domain as objects
* interconnected objects
* Any validation or calculation related to an object is placed in the object
* Delegates work to different objects
* Use of polymorphism to handle different buisness rules
* Use a template or strategy pattern to bring everything together

## Advantages

* Handles more complexity
* Avoid more conditionals, and adding more objects (polymorphism)

## Disadvantages

* lots of indirection, hard to see flow of logic
* complex data mapping
* object bloat
* Need to model domain in different layers


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hanfak.gitbook.io/workspace/general-paradigms/architecture/patterns/domain/domain-model.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
