On 02/16/2011 12:34 PM, Ricky Clarkson wrote:
If instantiating a real object is a problem (again assuming immutable
and without side-effects) then you might need to break up your objects
a bit more.
Well, it seems we're talking about simple, immutable objects. Ok. Let's now suppose that we're talking about objects that have partially immutable fields and partially not From a style point of view, what one should do? A consistent rule could be "public final fields" for "anything that is immutable", not "for anything that is immutable AND is part of an immutable object".

Furthermore, if we restrict immutable objects to the strict meaning of the term, we end up with anaemic objects (that is, things with no state, read-only javabeans). I hope that they are very few, possibly only some data types. In a real-world scenario I'm thinking of immutable objects that have also behaviour, relationships with other objects etc... hence the need of mocking.

--
Fabrizio Giudici - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
java.net/blog/fabriziogiudici - www.tidalwave.it/people
[email protected]

--
You received this message because you are subscribed to the Google Groups "The Java 
Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to