CRUD operations; do you notify whether the insert,update etc. went well ?

Posted by danielovich on Stack Overflow See other posts from Stack Overflow or by danielovich
Published on 2010-05-13T13:38:22Z Indexed on 2010/05/13 13:44 UTC
Read the original article Hit count: 192

Filed under:
|

Hi guys.

I have a simple question for you (i hope) :)

I have pretty much always used void as a "return" type when doing CRUD operations on data.

Eg. Consider this code:

public void Insert(IAuctionItem item) {
    if (item == null) {
        AuctionLogger.LogException(new ArgumentNullException("item is null"));
    }

    _dataStore.DataContext.AuctionItems.InsertOnSubmit((AuctionItem)item);
    _dataStore.DataContext.SubmitChanges();
}

and then considen this code:

public bool Insert(IAuctionItem item) {
    if (item == null) {
        AuctionLogger.LogException(new ArgumentNullException("item is null"));
    }

    _dataStore.DataContext.AuctionItems.InsertOnSubmit((AuctionItem)item);
    _dataStore.DataContext.SubmitChanges();

    return true;
}

It actually just comes down to whether you should notify that something was inserted (and went well) or not ?

© Stack Overflow or respective owner

Related posts about c#

Related posts about design