Click here to Skip to main content
15,890,825 members
Home / Discussions / C#
   

C#

 
QuestionException Handling / Response Question Pin
Kevin Marois20-Jun-14 6:45
professionalKevin Marois20-Jun-14 6:45 
GeneralRe: Exception Handling / Response Question Pin
PIEBALDconsult20-Jun-14 7:37
mvePIEBALDconsult20-Jun-14 7:37 
GeneralRe: Exception Handling / Response Question Pin
Kevin Marois20-Jun-14 7:39
professionalKevin Marois20-Jun-14 7:39 
GeneralRe: Exception Handling / Response Question Pin
PIEBALDconsult20-Jun-14 7:44
mvePIEBALDconsult20-Jun-14 7:44 
GeneralRe: Exception Handling / Response Question Pin
Kevin Marois20-Jun-14 7:52
professionalKevin Marois20-Jun-14 7:52 
GeneralRe: Exception Handling / Response Question Pin
PIEBALDconsult20-Jun-14 8:05
mvePIEBALDconsult20-Jun-14 8:05 
AnswerRe: Exception Handling / Response Question Pin
Eddy Vluggen20-Jun-14 8:05
professionalEddy Vluggen20-Jun-14 8:05 
GeneralRe: Exception Handling / Response Question Pin
Kevin Marois20-Jun-14 8:18
professionalKevin Marois20-Jun-14 8:18 
The problems I'm trying to address are

1) Try/Catch blocks All Over.

You always want try/catch's wrapping your DAL data methods. If you rely on catching exceptions in the UI, then other apps that use the DAL might not handle then properly and you open the door to corrupted data or unhandled exceptions.

When I see a method header like

void SomeFunction();



I don't know what's happening in the method, weather it's handling exceptions or not. But if I see this:

Response<SomeEntity> SomeFunction();


and I look at the Response and see an Exception property, then I can reasonably know that the method is handling exceptions in the DAL. I would still need to check the exception, but it might NOT be an exception. It could simply be some message suck as "Customer credit limit exceeded".

2) Provide a means to communicate other issues to the caller.

I do not agree that a duplicate record is an exception. First, it really is an issue of the business rules. Second, the user types in "Blah" and saves, and then "Blah" again and saves, and the app should log & throw?? Really? The app should notify the user, but no other action is necessary.

3). Provide a single point of handling problems, and a single method for returning info to the caller. There will most certainly be other applications accessing this data via the API. Since I don't know right now what they are, setting up the DAL to return responses instead of just throwing seems logical because I'm not relying on some other app or person to handle it. The DAL handles it and the programmer can do whatever they want with the response.

Just my 2 cents.
If it's not broken, fix it until it is

GeneralRe: Exception Handling / Response Question Pin
Eddy Vluggen20-Jun-14 9:21
professionalEddy Vluggen20-Jun-14 9:21 
GeneralRe: Exception Handling / Response Question Pin
Kevin Marois20-Jun-14 10:22
professionalKevin Marois20-Jun-14 10:22 
GeneralRe: Exception Handling / Response Question Pin
Eddy Vluggen20-Jun-14 11:05
professionalEddy Vluggen20-Jun-14 11:05 
QuestionPass specific object to a method expecting ref object parameter? Pin
arnold_w20-Jun-14 3:24
arnold_w20-Jun-14 3:24 
AnswerRe: Pass specific object to a method expecting ref object parameter? Pin
Richard Deeming20-Jun-14 3:58
mveRichard Deeming20-Jun-14 3:58 
GeneralRe: Pass specific object to a method expecting ref object parameter? Pin
OriginalGriff20-Jun-14 3:59
mveOriginalGriff20-Jun-14 3:59 
GeneralRe: Pass specific object to a method expecting ref object parameter? Pin
Richard Deeming20-Jun-14 4:01
mveRichard Deeming20-Jun-14 4:01 
AnswerRe: Pass specific object to a method expecting ref object parameter? Pin
OriginalGriff20-Jun-14 3:59
mveOriginalGriff20-Jun-14 3:59 
AnswerRe: Pass specific object to a method expecting ref object parameter? Pin
PIEBALDconsult20-Jun-14 7:41
mvePIEBALDconsult20-Jun-14 7:41 
AnswerRe: Pass specific object to a method expecting ref object parameter? Pin
Eddy Vluggen20-Jun-14 8:47
professionalEddy Vluggen20-Jun-14 8:47 
Questionwhen using Stored Procedure called from C# ? Pin
Member 245846719-Jun-14 21:46
Member 245846719-Jun-14 21:46 
AnswerRe: when using Stored Procedure called from C# ? Pin
OriginalGriff19-Jun-14 22:21
mveOriginalGriff19-Jun-14 22:21 
GeneralRe: when using Stored Procedure called from C# ? Pin
Member 245846720-Jun-14 22:58
Member 245846720-Jun-14 22:58 
GeneralRe: when using Stored Procedure called from C# ? Pin
OriginalGriff20-Jun-14 23:22
mveOriginalGriff20-Jun-14 23:22 
GeneralRe: when using Stored Procedure called from C# ? Pin
Member 245846720-Jun-14 23:41
Member 245846720-Jun-14 23:41 
GeneralRe: when using Stored Procedure called from C# ? Pin
OriginalGriff21-Jun-14 0:06
mveOriginalGriff21-Jun-14 0:06 
GeneralRe: when using Stored Procedure called from C# ? Pin
Member 245846721-Jun-14 13:49
Member 245846721-Jun-14 13:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.