I just read about Value Objects, being immutable and described as:
A small simple object, like money or a date range, whose equality isn't based on identity.
Looking at my currently existing entities I figured I could make pretty much everything that's not an entity a value object.
Let's say I have an entity class User.
class User
{
public $id;
public $firstname;
public $lastname;
public $email;
}
I could make it consist of the value objects Id
, FirstName
, LastName
, Email
and Password
, because none of these User
attributes equality are based on identity, right? But then again I could probably go even further and make more VOs Int
, String
, Name
(which consists of FirstName
and LastName
VOs), etc.
Where do I draw he line to prevent over-engineering?
Is it normal for a domain to contain that many VOs?
Is my understanding of value objects even right?