Click here to Skip to main content
15,912,897 members
Home / Discussions / C#
   

C#

 
GeneralRe: Throwing exception when a property must not be null? Pin
Martin Haesemeyer10-Sep-02 9:56
Martin Haesemeyer10-Sep-02 9:56 
GeneralRe: Throwing exception when a property must not be null? Pin
Paul Riley10-Sep-02 10:10
Paul Riley10-Sep-02 10:10 
AnswerRe: Throwing exception when a property must not be null? Pin
Erik Westermann9-Sep-02 7:43
professionalErik Westermann9-Sep-02 7:43 
GeneralRe: Throwing exception when a property must not be null? Pin
Paul Riley9-Sep-02 9:34
Paul Riley9-Sep-02 9:34 
GeneralRe: Throwing exception when a property must not be null? Pin
Erik Westermann10-Sep-02 4:06
professionalErik Westermann10-Sep-02 4:06 
GeneralRe: Throwing exception when a property must not be null? Pin
Paul Riley10-Sep-02 4:47
Paul Riley10-Sep-02 4:47 
GeneralRe: Throwing exception when a property must not be null? Pin
Erik Westermann10-Sep-02 15:37
professionalErik Westermann10-Sep-02 15:37 
GeneralRe: Throwing exception when a property must not be null? Pin
Paul Riley11-Sep-02 1:23
Paul Riley11-Sep-02 1:23 
Erik Westermann wrote:
It really depends on what you're designing and what its purpose will be. I'm speaking in the snese of who the immediate user is of course. For example, if you're building a class library, you'll probably end up throwing exceptions since you may have no other means of reporting an error or the best way to handle the error is to let the code that called the code in the class library handle the error.

I'd agree with you on both a class and an applicaton. Applications should avoid using Exceptions, though I admit I've been guilty of throwing an exception because I'm in the middle of a try block and want to act the same in the event of this error as I would if it were an exception.

That was, however, an ApplicationException.

I wouldn't agree with you in the case of a component - I don't see how this is different from a class library.

Erik Westermann wrote:
That was Microsoft's choice.

Sure, but it does show a total disregard for the selection of the namespace name "System". I feel you're taking that name a lot more seriously than those who designed it.

Erik Westermann wrote:
It is a system-level exception, System.ArgumentNullException is a derivative of System.SystemException. The naming standard appears to focus on the source of the exception, not the entity that casued it.

Except that an ArgumentNullException is NEVER going to be a result of a system problem, it's ALWAYS going to be a result of erroneous programming.

Thus, trying to catch system problems specifically simply by using catch (System.SystemException ex) is already a dangerous idea.

As Martin has pointed out, what if (for some reason I can't think of right now) you wanted to catch all exceptions caused by null arguments? Is it not unfair to expect people to catch the standard ArgumentNullException plus your ArgumentNullException plus my ArgumentNullException, etc, etc?

Paul
GeneralRe: Throwing exception when a property must not be null? Pin
leppie11-Sep-02 6:32
leppie11-Sep-02 6:32 
GeneralRe: Throwing exception when a property must not be null? Pin
Paul Riley11-Sep-02 7:04
Paul Riley11-Sep-02 7:04 
GeneralRe: Throwing exception when a property must not be null? Pin
leppie11-Sep-02 7:44
leppie11-Sep-02 7:44 
GeneralRe: Throwing exception when a property must not be null? Pin
Paul Riley11-Sep-02 13:26
Paul Riley11-Sep-02 13:26 
GeneralRe: Throwing exception when a property must not be null? Pin
leppie11-Sep-02 16:37
leppie11-Sep-02 16:37 
GeneralRe: Throwing exception when a property must not be null? Pin
Paul Riley11-Sep-02 23:43
Paul Riley11-Sep-02 23:43 
GeneralRe: Throwing exception when a property must not be null? Pin
leppie12-Sep-02 2:08
leppie12-Sep-02 2:08 
GeneralRe: Throwing exception when a property must not be null? Pin
Paul Riley12-Sep-02 2:52
Paul Riley12-Sep-02 2:52 
GeneralRe: Throwing exception when a property must not be null? Pin
leppie12-Sep-02 3:50
leppie12-Sep-02 3:50 
GeneralRe: Throwing exception when a property must not be null? Pin
Martin Haesemeyer10-Sep-02 10:06
Martin Haesemeyer10-Sep-02 10:06 
GeneralRe: Throwing exception when a property must not be null? Pin
Erik Westermann10-Sep-02 15:48
professionalErik Westermann10-Sep-02 15:48 
GeneralRe: Throwing exception when a property must not be null? Pin
jparsons10-Sep-02 5:07
jparsons10-Sep-02 5:07 
GeneralRe: Throwing exception when a property must not be null? Pin
stephen woolhead13-Sep-02 10:48
stephen woolhead13-Sep-02 10:48 
GeneralAdjusting colors Pin
Nnamdi Onyeyiri7-Sep-02 23:49
Nnamdi Onyeyiri7-Sep-02 23:49 
GeneralRe: Adjusting colors Pin
Stephane Rodriguez.8-Sep-02 0:25
Stephane Rodriguez.8-Sep-02 0:25 
GeneralRe: Adjusting colors Pin
Nnamdi Onyeyiri8-Sep-02 1:07
Nnamdi Onyeyiri8-Sep-02 1:07 
GeneralRe: Adjusting colors Pin
Nnamdi Onyeyiri8-Sep-02 1:44
Nnamdi Onyeyiri8-Sep-02 1:44 

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.