The domain allows you to define types and create objects representing your business model. Each object can have a set of attributes, which take parameters, functions or literals as value.
The Domain achieves two main goals:
- it allows you to organize your parameters and functions into business objects, creating an easy way to navigate your configuration;
- it creates a transparent way of accessing those parameters and functions from your application (or within Hyperon functions) without tying it down to specific parameter/function names, allowing you to only hardcode behaviour that is common to all objects of a given type, while maintaining the freedom to implement specific behaviours of each object individually.
Parameters and functions answer the question of how you would like to parameterize. Context answers the question of what parametrization can depend on. And least but not last -- domain answers the question of what you would like to parameterize.
Indeed, domain model is what we want to be configurable:
- using Menu-Model-Domain definition we can design domain types, their relationships and attributes;
- using Menu-Model-Domain configuration we can create instances of domain types and configure their attributes with use of parameters or functions.
Imagine, we want to configure life insurance products:
- each life insurance product consists of covers and funds;
- each cover has different maximum insurance sum, availability, premium logic, etc;
- each fund has different transfer fee, etc.
We can use Domain definition to define types for our domain, for instance:
Next, we can use Domain configuration to configure domain elements and their attributes:
Now, application connected to Hyperon can use any defined logic solely through domain layer. These are sample scenarios:
- getting all products from domain,
- getting all covers from product "PT3",
- getting all covers (from given product) with attribute is_available equal to true,
- calculate premium for given cover - just by getting value from base_premium attribute.
Read more on Domain in our Tutorials: