Giter Site home page Giter Site logo

Comments (1)

JavierCane avatar JavierCane commented on May 12, 2024 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 as private 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.