Generics List or Custom List
I’ve been thinking about whether the DBObject should use generics for returning lists or use a custom list object. I think from a coding perspective generics would seem like the easier choice. The DBObject user could just return List and presto you have a list of users! The down side is that you can’t add custom functions to the List object. Using the custom list we can create UserList: CollectionBase This would give us a list of user objects that we can add our own methods to.
Why do I think custom methods on the list are important? To prevent unnecessary calls to the Database. With UserList I could get all the users in a project, and then filter out just what I need for each control. Example:
UserList users = users.ByProject(5);DropDownList active.DataSource = users.Active();Repeater r_Newest = users.Newest(10);
So instead of making two Database calls for Active users and Newest users, I made one database call and just filtered the data I was looking for. I think this is very important to have as the applications scales.
On the other hand I could do something like make the DBObject keep a cache of it’s own data. That just feels like a problem waiting to happen. The only way I can conceive of that is to have an Object Factory
For now I’m just going to stick with the custom lists
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
