Simon,
On 9/25/15 11:44 AM, Simon Vocella wrote:
> I want to understand better what is a Value Object. I mean I understand
> that a Value Object is immutable and two value objects they are equal if
> their value are equals. Beyond this point:
>
> Do you think we can decide if an object could be a value object or is it
> something intrisic?
> I try a better explanation: many times when I see examples of value
> objects, I usually see String or Date, that they are obviously a value
> object, but if we think something more complex I start to doubt if they
> are really value objects or not.
> One example is the Response of a Web Application: some frameworks or
> libraries they return it as a new object and in this case it seems a
> value object, in other case they inject him and it seems a normal object.
Is a web response really a value object? Do you ever compare them by
value? Even for the same URL, don't they have differences, such as the
IP address of the requestor?
I think of a value object as something where the value IS it's identity.
In my experience, a web response is more of a bag of data than a value
object.
>
> Do you put validation or behaviours in value object?
Perhaps some convenience methods, especially for creation.
MyNumber number = MyNumber.fromString("5");
>
> How do you test it? With mock or with state-based test?
> I followed the TDD course of JB and He usually say: "never mock values".
> Do you agree with that?
How would you test a 5? Why not just use one?
- George
--
----------------------------------------------------------------------
* George Dinwiddie *
http://blog.gdinwiddie.com
Software Development
http://www.idiacomputing.com
Consultant and Coach
http://www.agilemaryland.org
----------------------------------------------------------------------