Lets say I have class called Connection
. One of his members is object that is instance of another class, class VerificationCode
.
The class VerificationCode
has 2 members: code
and expiresAt
.
Should I keep the VerificationCode
and associate it with the member, or should I associate the 2 members code
and expiresAt
directly to the Connection
class?
What are the advantages or disadvantages in terms of design/modeling?
Example:
Option 1:
Class VerificationCode{
code: string;
expiresAt: number;
}
Class Connection{
a: string;
verificationCode: VerificationCode;
}
Option 2:
Class Connection{
a: string;
code: string;
expiresAt: number;
}
Aucun commentaire:
Enregistrer un commentaire