Click here to Skip to main content
15,892,298 members
Home / Discussions / C#
   

C#

 
GeneralRe: knap sack Pin
Manfred Rudolf Bihy20-Apr-14 10:22
professionalManfred Rudolf Bihy20-Apr-14 10:22 
GeneralRe: knap sack Pin
Wes Aday20-Apr-14 10:31
professionalWes Aday20-Apr-14 10:31 
AnswerRe: knap sack Pin
OriginalGriff20-Apr-14 20:48
mveOriginalGriff20-Apr-14 20:48 
GeneralRe: knap sack Pin
harold aptroot21-Apr-14 7:17
harold aptroot21-Apr-14 7:17 
QuestionRe: knap sack Pin
ZurdoDev21-Apr-14 9:38
professionalZurdoDev21-Apr-14 9:38 
QuestionDAL Responses Design Question Pin
Kevin Marois20-Apr-14 7:52
professionalKevin Marois20-Apr-14 7:52 
AnswerRe: DAL Responses Design Question Pin
Ravi Bhavnani20-Apr-14 15:04
professionalRavi Bhavnani20-Apr-14 15:04 
GeneralRe: DAL Responses Design Question Pin
Kevin Marois21-Apr-14 6:35
professionalKevin Marois21-Apr-14 6:35 
1. AddLookup() should execute within a transaction, since a LookupEntity could be inserted between the check and your insert.

I agree

2. The case-insensitive string compare is flawed on several fronts: (1) A .ToLower() compare will not work across all cultures. Instead use .ToUpperInvariant(). (2) Performing a case conversion is a performance bottleneck, since your code won't scale. Try running the compare on a million records containing large strings. Instead, perform a case-insensitive using string.Equals() with StringComparison.OrdinalIgnoreCase.

I agree

3. The value of _ResponseBase.Message depends on the order in which the instance's properties are set. This is a VBT. _ResponseBase should instead offer various constructors that set its different properties, all of which should have protected setters and public getters.

First, what's a VBT?

Second, I've never been a fan of having various constructors just to set properties. In my app, I always create a response first, then later in the method I set the properties I need. Then return the instance. Using CTOR's means having different "new MyReponse(property = value)" all over each method.

4. Exceptions should be thrown, not returned. The only exception (pun intended) to this rule is when the thrown exception cannot be relayed across the network (e.g. ASP .NET MVC server exception to JS client layer

This point is the real reason for my posting...

One problem I was having is when an exception occurred in the DAL/BL, the controller only returns "An exception has occurred". So I decided to create the responses to that I would always get something back.

Also, I've heard people say "Exceptions should be thrown, not returned", but I have yet to see a compelling reason why. The UI needs to know about the exception somehow. I just return it, then re-throw it in my HandleResponse to my exception handling routine can handle it. I means less code, a single place to handle exceptions, and a known format coming back in all cases.

Having said all this, I'm not really sold on this design, so feel free to rebut.
If it's not broken, fix it until it is

GeneralRe: DAL Responses Design Question Pin
Ravi Bhavnani21-Apr-14 7:41
professionalRavi Bhavnani21-Apr-14 7:41 
GeneralRe: DAL Responses Design Question Pin
Kevin Marois21-Apr-14 8:10
professionalKevin Marois21-Apr-14 8:10 
QuestionHow to develop on Windows 7 64 bit and output x32 exe that uses x32 usb driver ? Pin
Mario 5620-Apr-14 2:46
Mario 5620-Apr-14 2:46 
AnswerRe: How to develop on Windows 7 64 bit and output x32 exe that uses x32 usb driver ? Pin
OriginalGriff20-Apr-14 3:43
mveOriginalGriff20-Apr-14 3:43 
GeneralRe: How to develop on Windows 7 64 bit and output x32 exe that uses x32 usb driver ? Pin
Mario 5620-Apr-14 6:32
Mario 5620-Apr-14 6:32 
Questionhow to code to c# method call on html anchor tag but that anchor tag is placed in datalist. Pin
Ayang1719-Apr-14 9:14
Ayang1719-Apr-14 9:14 
AnswerRe: how to code to c# method call on html anchor tag but that anchor tag is placed in datalist. Pin
Wes Aday19-Apr-14 10:35
professionalWes Aday19-Apr-14 10:35 
QuestionDoubleClick Selected Row Datagrid (C# WPF Project) Pin
rattlerrFx19-Apr-14 8:27
rattlerrFx19-Apr-14 8:27 
AnswerRe: DoubleClick Selected Row Datagrid (C# WPF Project) Pin
Wes Aday19-Apr-14 10:34
professionalWes Aday19-Apr-14 10:34 
GeneralRe: DoubleClick Selected Row Datagrid (C# WPF Project) Pin
rattlerrFx19-Apr-14 12:10
rattlerrFx19-Apr-14 12:10 
GeneralRe: DoubleClick Selected Row Datagrid (C# WPF Project) Pin
Wes Aday20-Apr-14 2:22
professionalWes Aday20-Apr-14 2:22 
GeneralRe: DoubleClick Selected Row Datagrid (C# WPF Project) Pin
rattlerrFx20-Apr-14 4:24
rattlerrFx20-Apr-14 4:24 
GeneralRe: DoubleClick Selected Row Datagrid (C# WPF Project) Pin
Wes Aday20-Apr-14 4:29
professionalWes Aday20-Apr-14 4:29 
SuggestionRe: DoubleClick Selected Row Datagrid (C# WPF Project) Pin
Richard MacCutchan19-Apr-14 21:20
mveRichard MacCutchan19-Apr-14 21:20 
QuestionDisplaying UTM coordinates on a form Pin
Member 1068390219-Apr-14 8:07
Member 1068390219-Apr-14 8:07 
QuestionDraw a Line within a class and inheritance Pin
Member 1075956718-Apr-14 16:55
Member 1075956718-Apr-14 16:55 
SuggestionRe: Draw a Line within a class and inheritance Pin
Richard MacCutchan18-Apr-14 22:04
mveRichard MacCutchan18-Apr-14 22:04 

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.