Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the difference between id & userId? #14

Open
amirh715 opened this issue Sep 19, 2020 · 1 comment
Open

What is the difference between id & userId? #14

amirh715 opened this issue Sep 19, 2020 · 1 comment

Comments

@amirh715
Copy link

amirh715 commented Sep 19, 2020

export class User extends AggregateRoot<UserProps> {

    get id (): UniqueEntityID {
        return this._id;
    }

    get userId (): UserId {
        return UserId.caller(this.id);
    }

    get email (): UserEmail {
        return this.props.email;
    }
        .
        .
        .
}

Why are there two id attributes in class User? one is named id and the other userId.
Why not use id : UniqueEntityID for all aggregates?
Also, the Function.caller seems to be deprecated.

@InfoLorenzo
Copy link

The ID identifies that unique entity in this moment and it's always an UUID,

You do not use this as UserID for a few possible reasons ( You can, but you force your design to this ):

  • Force your User domain entity to have an UUID as ID, so you won't be able to use a DB generated ID
  • You force the Value object of your Domain entity
  • In this model the way of working with UniqueEntityID Is not the same rather than working with Entity props

You can, of course you can but your force your domain model to work this way. The way that UniqueEntityID is build for.

Remember that is your have constraints for your domain model, in terms of identity that in your question, will be handled by UniqueEntityID class, you will have to modify this one, doing this you will be modifiying all the rest of ID's that well, for 1 function this won't be a big problem but in the long term that class, being used this way could have a big chance to become a big ball of mud.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants