every time I read about Domain Driven Design I feel I make my application structure more complex . like when using value objects .
if I have user Entity and user have email and password . in the Domain Driven Design I need to make new Email value object to hold the email string . why ?
Like @kramove said really, but also if you need to attach any kind of logic/functionality to a value.
Imagine you have a product weight you need to store. Within the value object you can have methods to convert to another unit type, or a formatting method that outputs the weight with the unit initials for the UI.
Currency conversation is another good example.
Pretty simple to have all that logic within a value object rather than in a controller or the UI itself, and it certainly isn't the responsibility of the model object to have that kind of logic.
In my opinion, I don't think weight or currency conversations are the responsibility of the product object, plus having that functionality in there as well could make for a pretty big class.
I used the weight/currency conversations as they wouldn't solely be used on a product object but in a cart object as well, and would therefore justify a value object.
If there was some logic relating solely to a product then of course there would be an argument to include the functionality directly within the product object, but I would still refer to part of my first point and large classes.
You don't have to do anything or follow any pattern. If you don't see any benefit to using a value object then you are just adding extra complexity. But always consider the big picture, I often sit here and wonder why the hell I'm using repositories when I can't see myself using anything other than Eloquent. But I have sites I have to work on that were written with no thought to maintainability and that make me want to hang myself!
Exactly @pobble, that's one point I didn't mention and should have, if you don't think its necessary to use a value object for your particular app then don't do it.
I'm not very into DDD. But I always wondered : why not making a package containing all kind of basic value objects like email / weight / currencies etc ?
@pmall Is this a US phone number or a globally-valid phone number? Should the phone number allow extensions? Sometimes it's way easier to create a six-line value object rather than include a package and then extend the USPhoneNumberWithoutExtension value object. ;)