Hello All,
I was reading this book : Expert C# 2005 Business Objects.
I find a good point of view about loading persitance data into a B.O. (
Business Object)
So I was wondering how with iBatis.net, you can resolves the list of
issues listed below :
*********************************************
... it can be challenging to efficiently get the data from the
persistence object into or out of the business object. For the
persistence object to load data into the business
object, it must be able to bypass business and validation processing in
the business object, and somehow load raw data into it directly. If the
persistence object tries to load data into the object using the object’s
public properties, you’ll run into a series of issues:
• The data already in the database is presumed valid, so a lot of
processing time is wasted
unnecessarily revalidating data. This can lead to a serious performance
problem when
loading a large group of objects.
• There’s no way to load read-only property values. Objects often have
read-only properties
for things such as the primary key of the data, and such data obviously
must be loaded
into the object, but it can’t be loaded via the normal interface (if
that interface is properly
designed).
• Sometimes properties are interdependent due to business rules, which
means that some
properties must be loaded before others or errors will result. The
persistence object would
need to know about all these conditions so that it could load the right
properties first. The
result is that the persistence object would become very complex, and
changes to the business
object could easily break the persistence object.
On the other hand, having the persistence object load raw data into the
business object breaks encapsulation in a big way, because one object
ends up directly tampering with the internal fields of another. This
could be implemented using reflection, or by designing the business
object to expose
its private fields for manipulation. But the former is slow, and the
latter is just plain bad object
design: it allows the UI developer (or any other code) to manipulate
these fields, too. That’s just asking for the abuse of the objects,
which will invariably lead to code that’s impossible to maintain.
************************************
I would like to know what do you think about it ?
How do you use the iBatis.net framework to load persitance DATA into the
Business object ?
your Best pratices
Do we need to use DTO ?
etc .
Thanks