Title: Message
it depends on the semantics of the app: if those DTO's are not to be modified by the people obtaining references to them, at least directly, then they should be inmutable; or mutable otherwise. Inmutable DTO's might be cached more efficiently since you know they need not to be written back to the DB. Inmutable DTOs could also be optimized for serialization. But basically, it's a matter of your business rules, and encapsulation. There's a bunch of articles on the subject (including versioning support for mutable DTOs) in theserverside.com.
 
I use mutable DTOs as a rule of thumb, and decide whether or not to persist into the DB based on a set of business rules, which mainly take into account that the logged in user has modify permissions on that particular Entity instance (or DB record, if you will). Since I usually build libraries to be used by third parties and there's the possibility of malicious use of my apps, I don't rely on plain Java to ensure that a DTO class is inmutable(esp. with the bugs in reflection in some JDKs).
 
My 2c,
 
 
Juan Pablo Lorandi
Chief Software Architect
Code Foundry Ltd.

Barberstown, Straffan, Co. Kildare, Ireland.
Tel: +353-1-6012050  Fax: +353-1-6012051
Mobile: +353-86-2157900
www.codefoundry.com
 
Disclaimer:
 
Opinions expressed are entirely personal and bear no relevance to opinions held by my employer.
Code Foundry Ltd.'s opinion is that I should get back to work.
-----Original Message-----
From: A mailing list for Enterprise JavaBeans development [mailto:[EMAIL PROTECTED] On Behalf Of Glenn Dickson
Sent: Wednesday, March 19, 2003 12:41 AM
To: [EMAIL PROTECTED]
Subject: Re: Value Object - mutable/immutable

Sure Denis but when is it appropriate to use immutable VOs and mutables?
 
 
Glenn
----- Original Message -----
From: Denis Wang
Sent: Tuesday, March 18, 2003 9:20 PM
Subject: RE: Value Object - mutable/immutable

don't you have setters in your vo's? definitely mutable.
denis
-----Original Message-----
From: A mailing list for Enterprise JavaBeans development [mailto:[EMAIL PROTECTED]On Behalf Of Glenn Dickson
Sent: Tuesday, March 18, 2003 3:02 AM
To: [EMAIL PROTECTED]
Subject: Value Object - mutable/immutable

Just wondering what people view are about VOs being either Mutable or non-mutable, I have heard/read that VO should be Immutable while transferring data. If the data needs to be changed then a new VO object is generated.
 
Any view pls?
Thanks
Glenn

Reply via email to