Mulitple DataPortal_XYZ

Mulitple DataPortal_XYZ

Old forum URL: forums.lhotka.net/forums/t/3980.aspx


griff posted on Tuesday, December 04, 2007

Hi

I know you use an editable root object (ERO) for retrieving updating the database. what do people do in this scenario...

A table with many fields 30, 50, >100 say.

One main user screen to do typical CRUD operations using the ERO

But another specific user screen (or process) that needs access to serveral/many of the table's/ERO data items for viewing purposes and in this instance only ever updates one (or two) of the data items.

It seems overkill to call the main ERO data_portal_xyx update stored proc updating 30, 50, >100 fields.

So would I create a second data_portal_xyx and execute a simple stored proc updating that one field or create/use the CommandBase object within BO or what?

Richard

 

 

 

 

richardb replied on Tuesday, December 04, 2007

I wouldn't say it was overkill to do the update with just the one DataPortal_Update method and one stored procedure.  In fact it's a good idea, generally.

If you start creating lots of different methods calling different stored procedures to update different columns in the table, you have increased your code maintenance effort. 

Of course if that's what you want to do its your choice.

Richard B.

griff replied on Tuesday, December 04, 2007

I tend to agree.  Just that I was challenged by someone who thought updating 130 fields in the table (thru stored proc) when in this instance the user will be only actually updating one field, and so suggested a simple "Update tblX set myfield='xyz' where .....".

Richard

 

JoeFallon1 replied on Tuesday, December 04, 2007

Your first use case is the entire table and the ERO makes total sense.

But the 2nd use case is a subset of various BOs. It should probaly be its own BO and in its DataPortal you would run the "simple" update statement that was suggested to you.

Joe

 

ajj3085 replied on Tuesday, December 04, 2007

I agree with Joe.

griff replied on Tuesday, December 04, 2007

Thanks for the replies.  I'm still not sure which way to go. Keep your thoughts coming.

ajj3085 replied on Tuesday, December 04, 2007

Well remember, you have two use cases, so you should have two sets of objects to fulfill those use cases.  This will make maintence much much easier, which is our goal.  A large object that has switches to make it do only a subset can get messy quickly, especialy if you have other use cases which end up being similar, but not the same.

griff replied on Tuesday, December 04, 2007

Hi

So we have serveral use (very similar) cases each fetching and loading a full object but differing only in the data_portal_update method?

So if it's acceptable for the BO to have serveral  DataPortal_Fetch overload methods (using different criteria) then why not overload the DataPortal_Update method?

Richard

 

 

Richard

ajj3085 replied on Tuesday, December 04, 2007

You could, it will just make it more difficult to maintain.  What if the switch that controls which update to do doesn't get set properly?  Some of it depends though on how complicated that logic will be.  some of it depends on how complicated it could be come if the use case is changed later..

You can create another internal class which will do the load and populate these BOs.  That will allow you to re-use the fetch code and still have seperate BOs to do the update.  The BOs can have a shared interface which is what your loader class will use to push values into them. 

HTH
Andy

cliffordru replied on Tuesday, December 04, 2007

If you look at it from a responsibility perspective, you should have one BO responsible for updating all fields and another BO for updating the few specific fields. This seems to be in line with your use cases and two BO will prevent them from being dependent upon one another.

Copyright (c) Marimer LLC