Comments (1)
Hi @Miczeq22!
Good one, thanks for pointing it out ๐
We normally leave the default constructor set as public
in order to be able to reconstruct that entity in a specific state without recording any events. That is usually useful for instance while recovering it from the database, or while instantiating it for a specific test case.
It is true that right now we are using the fromPrimitives
method in our Mongo repositories and in the Elasticsearch ones, but the ObjectMothers would be still needing that default constructor.
Here we have two alternatives:
- Using the
fromPrimitives
also in our ObjectMothers in order to be able to set asprivate
the default constructor - Leave the default constructor as
public
and assume that the fact that we shouldn't use it from our use cases in order to avoid missing out any domain event recording is a convention not enforced by code.
Taking into account that trade-off, we would opt for the second option. Why:
- We don't want to assume more complexity in each of our ObjectMothers
- We understand that the development team has enough maturity regarding these topics in order to assume that convention
This is a decision that could be reconsidered in a future ๐
from typescript-ddd-example.
Related Issues (12)
- [Question] - Error de dependencia circular en application service con commandBus HOT 2
- Unnecesary await
- Absolute Imports ๐ค
- Should the controller expect Domain Errors from the command bus? HOT 2
- Coupling the infrastructure layer to the domain layer.
- Update typeorm
- Problemas con dependency-injection cuando se compilar para producciรณn HOT 2
- Make Template HOT 1
- Middleware question HOT 2
- Just a small question
- Is there a course of this? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typescript-ddd-example.