Design Patterns · Senior · Question 29 of 75
What distinguishes a Value Object?
- ✓Correct answer: Equality by value, immutability, its own invariants
- 2The object stores only numeric values
- 3The object is created only via a singleton factory
Explanation
Money(100, 'USD') equals another Money(100, 'USD'), and operations return new objects. Validation in one place rules out a "negative amount" throughout the code. In TS, branded types with factories are close to this.