Rich Domain (business objects) Qustion

C

cmay

I am trying to build more applications using a more OO approach, with
more seperation of business and presentation logic.

One problem I am running into involves the design philosophy behind
using a rich domain.


Lets say that for a specific page you need to view all the line items
for a given order, and produce some aggregrate information about those
line items.

Now, the cheap and dirty method would be to just fetch a dataset, loop
through it to do any aggregrate calculations you need for the footer,
and then databind it to a datagrid.

If you were to do this same task w/ a rich domain model, you would
probably get an Order object that contained a collection of Line Items.

This means you would have to instantiate an object for every line item,
only to turn around and do nothing while those items (other than just
databinding the results to a datagrid).


So, am I designing this correct, or is there a better way to do this?
How do people who follow the rich domain model deal with issues like
this? In this example, there usually wouldn't be a ton of line items,
but in other applications you could have hundreds of items. I am
thinking the performance penality would be really large.
 
S

Scott Allen

Hi cmay:

It always depends on the application, but a DataSet object is a
reasonable choice if you only need read-only aggregate information.
It's especially nice to do all the aggregation work in the database
with a GROUP BY, because database engines are particularly good at
this.

In terms of populating hundreds of LineItem objects, it might be just
as expensive to populate hundreds of rows in a DataGrid - they are not
the lightest weight object in the framework...
 
C

cmay

Scott,

Thanks for the reply.

Can I ask another question: (2 parter) How do most objects (which are
representing data from a database) handle Null values? When you are
accessing a dataset, you can check if the value is DBNull.Value, but if
you are strongly typing the properties of your object, how do you do
that? Do you type them as nullable types?
Also, with a dataset you can extract a view for sorting and filtering
before binding to a datagrid. Is there anything similar w/ objects
that once can implement, or do you have to write your own code to order
/ filter your collection of objects?
 
S

Scott Allen

I have not tried nullable types enough to be comfortable with them yet
(the nullable types in 2.0, that is).

In general I've tried to avoid the problem by using NOT NULL columns
in the database design. When forced to I've used the nullable Sql
types like SqlDateTime.

For sorting and filtering I've relied on the database, too. Although
you can (and would have to) write your own filtering and sorting using
something like: http://odetocode.com/Articles/203.aspx, I try to pull
records back from the database in order and keep them in an ordered
ArrayList.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top