You also loose lazy loading capability by using fields instead of
properties - although it might not matter for you.
On 5/10/2010 6:30 a.m., Patrick Steele wrote:
I understand your scenario. As you stated, you need method calls to
initialize your data. That is a form of encapsulation.
All I'm saying is that exposing your private fields to modification
from outside the class *is* breaking the concept of encapsulation.
I've had scenarios like yours before (where bad data in the DB needs
to be loaded/displayed). In those cases, my ORM objects are
dead-simple POCO's with getters/setters. I then used a higher-level
"domain" object that had my validation and business logic. Using
something like Automapper made moving the data back-and-forth pretty
easy.
---
Patrick Steele
http://weblogs.asp.net/psteele
On Mon, Oct 4, 2010 at 1:16 PM, MWightman<[email protected]> wrote:
Actual it is not. I all my object initialization via constructor and
require a fully valid object. I use a private no arg for ORM usage.
My objects have methods not many getters/setters, I do not use
getters/setters unless they are truly called for.
If data in the database is invalid it is still necessary that the
object be re-hydrated to allow for correction. if the data had to
pass the validation of getter/setters it would fail.
Example objejct
I would like to set all of the private fields with no need to any
getters/setters
public class order
{
private Iset<orderline> _lines
private IAddress _address
private bool _shipped;
public Submit()
{
if (_lines.count!=0)
{
_shipped=true;
}
else
{
throw new exception()
}
}
}
On Oct 4, 10:24 am, Patrick Steele<[email protected]> wrote:
Um, that's the *opposite* of encapsulation. By giving access to
private fields, anyone can change the value of the field -- so the
access to the fields is no longer encapsulated to just your
getters/setters.
---
Patrick Steelehttp://weblogs.asp.net/psteele
On Mon, Oct 4, 2010 at 7:52 AM, MWightman<[email protected]> wrote:
I would much prefer to map to private fields not public properties for
the sake of encapsulation. Can AR map relations and collections to
private fields?
Thanks
--
You received this message because you are subscribed to the Google Groups "Castle
Project Users" 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
athttp://groups.google.com/group/castle-project-users?hl=en.
--
You received this message because you are subscribed to the Google Groups "Castle
Project Users" 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/castle-project-users?hl=en.
--
You received this message because you are subscribed to the Google Groups "Castle
Project Users" 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/castle-project-users?hl=en.