blah blah blah is here! blah blah » Close

up0down
link

Hi,
Assume i have a form that has three fields (all textboxes). I can find an Item by ItemNo. When item is found the detail, ItemName and ItemWeight is loaded to the other two textboxes. User updates the "Item Wieght".
The logic would say that i need to write three update routine (overloaded) that :
1. update(String strItemName) {....} this will update the Item object ONLY if the user updates Item's Name
2. update(String strItemWeight) {....} this will update the item object ONL if the user updates Item's Weight.
3. update(String strItemName, strItemWeight) {....} this will update hte item object ONLY if the user updates both ItemName and Item Weight.
Therefore in the data access layer i have to write three routines that will map to above three rotines also i need to write three stored procedure
1. update the itemtable's ItemName column only if user updates Item's name
2. update the itemtable's ItemWeight column only if user updates Item's Weight
3. updates itemtable's ItemWeight and ItemName columns only if user updates both name and weight of the item.
Is this the standard way of coding for update operations?
PS: I[m using stored procedures in the data layer!
cheers

last answered 2 years ago

1 answers

up0down
link

You may think about to use just 2 methods and not 3, because it's doesn't really matter if you call both update(String strItemName) and update(String strItemWeight) or just call update(String strItemName, strItemWeight), so I think that the third is unnecessary.
And you can't execute 2 update(String) method!
And who does call the update method, the Form event?

up0down
link

"And who does call the update method, the Form event? "
Another class (a controller).
However, if i follow this technique then if there are 7 fields how manh permuations and combination can make that equal to number methods ......

This post was imported from csharpfriends, if you have a similiar question please ask it again.

All previous members have been migrated, hope you enjoy the new platform!

Feedback