Back to list
Views:   11.3K
Replies:  3

Dto fields vs. properties

Noticed 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 1
Yes, 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 2
The messages are serializable too but all of them have fields. Correct if I'm wrong.
Michael S, Jan 11, 2012
Reply 3
DTO'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
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.