Click here to Skip to main content
15,901,001 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Localization doesn't work, please help!!! Pin
jaimachu30-Nov-07 0:39
jaimachu30-Nov-07 0:39 
QuestionHow to add Microsoft Word features to .Net application Pin
ugs197813-Nov-07 20:24
ugs197813-Nov-07 20:24 
AnswerRe: How to add Microsoft Word features to .Net application Pin
DigiOz Multimedia14-Nov-07 11:49
DigiOz Multimedia14-Nov-07 11:49 
QuestionAbout RowDataBound Pin
geeta pavate13-Nov-07 20:19
geeta pavate13-Nov-07 20:19 
QuestionTo use or not to use exceptions? Which is the preferred approach? Pin
boinske13-Nov-07 16:22
boinske13-Nov-07 16:22 
AnswerRe: To use or not to use exceptions? Which is the preferred approach? Pin
ugs197813-Nov-07 20:34
ugs197813-Nov-07 20:34 
AnswerRe: To use or not to use exceptions? Which is the preferred approach? Pin
Urs Enzler13-Nov-07 21:33
Urs Enzler13-Nov-07 21:33 
AnswerRe: To use or not to use exceptions? Which is the preferred approach? Pin
Colin Angus Mackay14-Nov-07 23:21
Colin Angus Mackay14-Nov-07 23:21 
boinske wrote:
A) throw an exception whenever a negative weight is supplied to your function


Might I suggest an ArgumentOutOfRangeException[^] for this.


boinske wrote:
B) do not throw an exception, but use a return object or property to indicate that an invalid argument was supplied, and set the actual return value to zero.


No. The caller should be aware of the range of permitted arguments therefore any argument that is not valid should be rejected with an exception. It is an exceptional circumstance that the method receives an out of range argument.


boinske wrote:
You know that, if you choose option A, your component may crash the application if the developer of that application did not anticipate and handle potential exceptions.


Not your problem. If the developer using the component isn't keeping within the defined parameters then that is their fault. The .NET Framework throws exceptions all the time. What do you do with them? You either fix the problem that caused the exception or handle them in a catch block somewhere.

Just make sure that the limits are clearly documented and the exception message explains what went wrong.

boinske wrote:
This has been the topic of a week-long, heated debate in our group. We all have very strong opinions for option A or B. Seriously, any input is appreciated. Please do not hold back in expressing your opinion on this!


It shouldn't be the subject of a heated debate. The answer is a no brainer. Use exceptions. There is even an exception in the framework for this.

I should stress that regardless of what option you choose you WILL be blamed for bugs and errors that are not yours. With exceptions you at least have the opportunity to deflect some of that by indicating in the exception message what caused the problem.


AnswerRe: To use or not to use exceptions? Which is the preferred approach? Pin
Pete O'Hanlon15-Nov-07 0:16
mvePete O'Hanlon15-Nov-07 0:16 
AnswerRe: To use or not to use exceptions? Which is the preferred approach? Pin
mabo4215-Nov-07 6:55
mabo4215-Nov-07 6:55 
AnswerRe: To use or not to use exceptions? Which is the preferred approach? Pin
PIEBALDconsult19-Nov-07 14:04
mvePIEBALDconsult19-Nov-07 14:04 
QuestionMSBuild - Building multiple projects Pin
Simon P Stevens13-Nov-07 5:06
Simon P Stevens13-Nov-07 5:06 
AnswerRe: MSBuild - Building multiple projects Pin
Scott Dorman13-Nov-07 12:45
professionalScott Dorman13-Nov-07 12:45 
GeneralRe: MSBuild - Building multiple projects Pin
Simon P Stevens15-Nov-07 1:39
Simon P Stevens15-Nov-07 1:39 
QuestionForm above another Form, but not TopMost? Pin
AndrewVos13-Nov-07 2:47
AndrewVos13-Nov-07 2:47 
AnswerRe: Form above another Form, but not TopMost? Pin
Luc Pattyn13-Nov-07 3:16
sitebuilderLuc Pattyn13-Nov-07 3:16 
GeneralRe: Form above another Form, but not TopMost? Pin
AndrewVos13-Nov-07 3:20
AndrewVos13-Nov-07 3:20 
QuestionReference of VB6 COM & Activex components in VB.net setup : Need urgent help [modified] Pin
nishkarsh_k12-Nov-07 23:46
nishkarsh_k12-Nov-07 23:46 
AnswerRe: Reference of VB6 COM & Activex components in VB.net setup : Need urgent help Pin
Paul Conrad13-Nov-07 13:01
professionalPaul Conrad13-Nov-07 13:01 
AnswerRe: Reference of VB6 COM & Activex components in VB.net setup : Need urgent help Pin
DigiOz Multimedia13-Nov-07 13:27
DigiOz Multimedia13-Nov-07 13:27 
QuestionLogonUserA API always throws 1326 (Incorrect Username and Password) Pin
Vasudevan Deepak Kumar12-Nov-07 22:48
Vasudevan Deepak Kumar12-Nov-07 22:48 
QuestionInstaller issue vb2005 : Need urgent help Pin
nishkarsh_k12-Nov-07 20:24
nishkarsh_k12-Nov-07 20:24 
AnswerRe: Installer issue vb2005 : Need urgent help Pin
Michael Sync12-Nov-07 20:35
Michael Sync12-Nov-07 20:35 
GeneralRe: Installer issue vb2005 : Need urgent help Pin
nishkarsh_k12-Nov-07 21:57
nishkarsh_k12-Nov-07 21:57 
Questionodp.net error Pin
umashankergr812-Nov-07 10:07
umashankergr812-Nov-07 10:07 

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.