J
jehugaleahsa
Hello:
We have a fairly small shop where I work. Most of our applications are
database driven, taking data from a database table and displaying it
on a form for editing. We are trying to apply a 3-layer architecture,
but I feel like we are missing something.
For us, business objects have always been classes with properties for
each column in a table. However, from what I have read, it sounds like
this really isn't a very good definition for a business object. The
reason I say this is because I feel as though the business object is a
little too aware of the database and has no real business logic
associated with it.
For instance, a "business object" could simply be a bunch of private
fields for each column with public properties for each. At some point,
the database results must be stored to the business object. The data
access layer may deal with assigning all the properties, but it still
seems like the business object is just a mapping of the database
fields. Many authors make it sound as though business objects are more
than just representations - that they have methods for executing
business logic.
Well, obviously, somewhere the transition from the database to an
object is needed. So, I'm not sure what is bothering me here. The
question is, where is all our domain logic? In our applications, like
I said, we essentially just dump the database information to a form.
In that case, can there be such a thing as a business layer?
Our business objects almost always look like this:
MyBO:
<list of properties>
<static method for select>
<instance methods for insert, update and delete>
A long time ago, we used to keep the methods out in a factory class,
but we found it really didn't buy us anything.
Perhaps our applications just lack the domain logic. Is creating a
mapping of the database table sufficient to be considered a domain
layer?
Another question: Over the time we have been developing, we stopped
using private fields for our values. Instead, we pass a DataRow/
IDataRecord to the business object's ctor. We write our properties so
that all they do is index into the row/record. This has worked great
because it saves us from either passing a large number of values to
the ctor or setting each property individually. While this saves code,
it means our business objects suddenly need to know a lot more about
our databases. Is this a bad thing? Does this move our business
objects more toward the data access layer than the domain layer?
Thanks for any input,
Travis
We have a fairly small shop where I work. Most of our applications are
database driven, taking data from a database table and displaying it
on a form for editing. We are trying to apply a 3-layer architecture,
but I feel like we are missing something.
For us, business objects have always been classes with properties for
each column in a table. However, from what I have read, it sounds like
this really isn't a very good definition for a business object. The
reason I say this is because I feel as though the business object is a
little too aware of the database and has no real business logic
associated with it.
For instance, a "business object" could simply be a bunch of private
fields for each column with public properties for each. At some point,
the database results must be stored to the business object. The data
access layer may deal with assigning all the properties, but it still
seems like the business object is just a mapping of the database
fields. Many authors make it sound as though business objects are more
than just representations - that they have methods for executing
business logic.
Well, obviously, somewhere the transition from the database to an
object is needed. So, I'm not sure what is bothering me here. The
question is, where is all our domain logic? In our applications, like
I said, we essentially just dump the database information to a form.
In that case, can there be such a thing as a business layer?
Our business objects almost always look like this:
MyBO:
<list of properties>
<static method for select>
<instance methods for insert, update and delete>
A long time ago, we used to keep the methods out in a factory class,
but we found it really didn't buy us anything.
Perhaps our applications just lack the domain logic. Is creating a
mapping of the database table sufficient to be considered a domain
layer?
Another question: Over the time we have been developing, we stopped
using private fields for our values. Instead, we pass a DataRow/
IDataRecord to the business object's ctor. We write our properties so
that all they do is index into the row/record. This has worked great
because it saves us from either passing a large number of values to
the ctor or setting each property individually. While this saves code,
it means our business objects suddenly need to know a lot more about
our databases. Is this a bad thing? Does this move our business
objects more toward the data access layer than the domain layer?
Thanks for any input,
Travis