Where do you like to draw the line for modeling a single value as a Value Object v.s. a primitive? For example if I have an internal order number and a customer order number, would you model them both as Value Objects even if they only contain a single string attribute and no special validation? I see the benefit it adds for type safety and readability, but how much is too much? At what point is a primitive ok? I'm starting to find that in my current project I am modeling everything as a Value Object and it's starting to feel bloated.
Thanks for any feedback in advance!
IEquatable. – Robert Harvey Sep 16 '21 at 22:00createOrder(InternalOrderNumber internalOrderNumber, CustomerOrderNumber customerOrderNumber)v.s. the alternativecreateOrder(String internalOrderNumber, String customerOrderNumber), which would allow any type of String, perhaps even accidentally passing variables in the wrong order. 2. Readability. To me, seeing code likeList<PhoneNumber> phoneNumberslooks a lot better thanList<String> phoneNumbers. This could also help when developers choose poor variable names. 3. Searchability. Want to see all uses ofPhoneNumber? Easy. With a String? Good luck. – secondbreakfast Sep 17 '21 at 02:05insert old man Captain America meme"No, I don't think I will" – secondbreakfast Sep 17 '21 at 04:19IComparableimplementations solve the searching and sorting problems, and most developers worth their salt understand how a string works. At the end of the day, it's always a value judgement; there's seldom a clear-cut case of right or wrong. – Robert Harvey Sep 17 '21 at 12:55