opcotech/elemo

View on GitHub
docs/ADRs/0015.assigning-values-before-creation.md

Summary

Maintainability
Test Coverage
# Assigning Values Before Creation

| author       | created at | updated at     | status   |
|:-------------|:-----------|----------------|:---------|
| @gabor-boros | 2023-04-04 | _current date_ | accepted |

## Abstract

There are many places in the system when we have to create, update, or delete
a resource. In some of these cases, we have to assign values to the resource,
like creation time, or the ID of the resource that is being created. This ADR
describes where, how, and why we assign these values.

## Decision

We assign values on the repository level, before the resource is created,
updated, or deleted. We do this because the repository layer must create
auxiliary resources on the fly, like relations between resources, therefore
separating the same logic (assigning values) to multiple places would be
more error-prone.

## Consequences

On the long run, this decision will make the system more consistent, and
easier to maintain. However, there is a small chance that we will have some
surprises when we want to assign values on service layer that will be
overridden by the repository layer.

## References

None.