Groups | Blog | Home
all groups > dotnet distributed apps > december 2004 >

dotnet distributed apps : Returning Model object as ArrayList or DataTable. Which one is good?


GoodMorningSky
12/10/2004 12:24:53 PM
Hi, all...
Whenever I create Business layer component, I wonder which object should I
return between Model object as ArrayList or DataTable?

For example,
1.
//return ArrayList containing Model.ProductInfo objects
//this method just Get DataReader and create ProductInfo objects, add to
ArrayList and return
//the ArrayList as IList
public IList GetProductByCategory(string category);

2.
//Gets DataTable using DataAdapter class
// and return it.
public DataTable GetProductByCategoryASTable(string category);


Which one is better?
Most of Distributed application methods use 1. But, It's hard to bind the
result to DataGrid.
I have to Create DataTable by looping through the IList.

2. is good to bind to DataGrid by setting DataSource property. But,
presentation layer developer have to know DataTable's schema info.

For my self, I create both method version and call it as it needs.
But, I don't feel comfortable using DataTable, since it seems not good
pattern/architecture...
I don't know why exactly I feel this way..

Please give me advice and which one is better or how industry uses, and
which one is better for a certain situation or any other comment will be
good.

Thank you...

Sam Santiago
12/10/2004 5:54:09 PM
I vote for #1. The least amount of dependecy on the underlying data object
model -A DO.NET in this case - the better. Do you remember how Microsoft's
data object models have changed over the years - RDO, ADO (various version),
and the ADO.NET. Did you know that you can also bind your ArrayList of
objects to your DataGrid? Any object that implements the IList interface
can be bound. Check out these links for details:

Binding Class
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsbindingclasstopic.asp

Microsoft Windows Forms DataGrid Control: An Introduction
http://support.microsoft.com/?scid=http://support.microsoft.com%2Fservicedesks%2Fwebcasts%2Fen%2Fwc090502%2Fwct090502.asp

Good luck.

Thanks,

Sam


--
_______________________________
Sam Santiago
ssantiago@n0spam-SoftiTechture.com
http://www.SoftiTechture.com
_______________________________
[quoted text, click to view]

AddThis Social Bookmark Button