akai-org / akai-org/put-wiki

Replace Guid type Ids of domain entities to value objects

Open
#151 0 comments 0 reactions 0 assignees View on GitHub
area:backend type:task
Dominant language
TypeScript
Stars
6
Forks
3
Avg merge
3d 17h
Merged PRs (30d)
15

Description

## Summary
Currently in domain layer `Id` of entities that is domain concept use `Guid` type, which can lead to unclear code and bugs (I can't be sure whether I pass Guid of one entity instead of another). Wrapping an Id in a value object makes it type-safe and improves code semantics.

Before implementing this task: what is value object?
https://martinfowler.com/bliki/ValueObject.html
https://stawarczyk.pl/2020/09/value-object-podstawowy-element-domain-driven-design/
https://antondevtips.com/blog/a-modern-way-to-create-value-objects-to-solve-primitive-obsession-in-net#what-are-value-objects

## [Acceptance criteria](https://www.atlassian.com/work-management/project-management/acceptance-criteria)
- [ ] Replace Guid Ids in all domain entities to value objects. Remember that these Ids of domain entities are domain concept, therefore they shouldn't leak into other layers of our application
- [ ] Update ef core mapping config to map value objects to values that can be persisted in db

## Notes
when for example:
aggregate A needs to reference aggregate B via aggregate root `BAggregateRootId` value object then should aggregate A use directly that value object (which introduces dependency between aggregates) or have their own value object that represents id of B aggregate root?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.