Views: 11.3K
Replies: 3
Archived
|
Dto fields vs. propertiesNoticed that in the Service layer message classes you use fields but in DTOs you use properties. Any reason why?
Michael S, Sep 14, 2011
|
|
Reply 1Yes, a very valid point. After some reflection I can now see that fields and properties are able to be serialized. I guess the only other reason to use properties is because properties are bindable and fields (variables) are not. Added to that if you use reflection to reference these things then I think the behaviour is slightly different.
I always thought that fields were not serializable.... I now know they are so that is good! Dan Bambling, Jan 11, 2012
|
|
Reply 2The messages are serializable too but all of them have fields. Correct if I'm wrong.
Michael S, Jan 11, 2012
|
|
Reply 3DTO's use properties because DTO's need serialize and de-serialize. Fields are not able to. Therefore your DTO needs to be marked as serializable.
Dan Bambling, Jan 11, 2012
|