Click here to Skip to main content
15,921,212 members
Home / Discussions / C#
   

C#

 
GeneralRe: Serious MDI frusteration Pin
Daniel Turini30-Apr-03 5:48
Daniel Turini30-Apr-03 5:48 
GeneralRe: Serious MDI frusteration Pin
RB@Emphasys30-Apr-03 6:41
RB@Emphasys30-Apr-03 6:41 
GeneralRe: Serious MDI frusteration Pin
RB@Emphasys30-Apr-03 8:04
RB@Emphasys30-Apr-03 8:04 
QuestionGetting version number of browser control process? Pin
LongRange.Shooter30-Apr-03 4:29
LongRange.Shooter30-Apr-03 4:29 
AnswerRe: Getting version number of browser control process? Pin
Stephane Rodriguez.30-Apr-03 4:50
Stephane Rodriguez.30-Apr-03 4:50 
GeneralAsserts vs. ArgumentExceptions Pin
Alvaro Mendez30-Apr-03 4:02
Alvaro Mendez30-Apr-03 4:02 
GeneralRe: Asserts vs. ArgumentExceptions Pin
perlmunger30-Apr-03 4:48
perlmunger30-Apr-03 4:48 
GeneralRe: Asserts vs. ArgumentExceptions Pin
Alvaro Mendez30-Apr-03 5:32
Alvaro Mendez30-Apr-03 5:32 
Yes, but what about this specific case where I need to verify that method parameters are valid? I've always used assertions to check these, but I've somehow felt that they're not robust enough since they get compiled away in Release mode. Now with these handy new exception classes, it seems like I can kill 2 birds with one stone: verify that parameters are valid, and if not stop the execution to notify myself and maybe the end-user, if the bug slips through the cracks.

I guess a distinction could also be made between different types of code:

1. Code executed directly from an end-user's action, such as a button-click handler.
2. Code exposed publicly by a class library.
3. Code which is internal or private to a class library.

I can see how for the first two types of code exceptions should be used to enforce that the end-users of the software or callers of public methods of a class library do not send invalid parameters. Indeed that's how most (if not all) of the methods in the .NET library work. If a parameter is not valid, an exception is thrown.

However, for the third type of code, assertions seem more appropiate since it's the responsibility of the programmer that the parameters passed to those methods are valid. So the assert statements provide a safety net during the development/test phase.

Well, I guess I've answered my own question then. Smile | :)

Regards,
Alvaro


When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com
GeneralCasting Pin
apollo-house30-Apr-03 3:02
apollo-house30-Apr-03 3:02 
GeneralRe: Casting Pin
Stephane Rodriguez.30-Apr-03 3:34
Stephane Rodriguez.30-Apr-03 3:34 
GeneralRe: Casting Pin
Nathan Blomquist30-Apr-03 7:43
Nathan Blomquist30-Apr-03 7:43 
GeneralCasting Pin
apollo-house30-Apr-03 3:01
apollo-house30-Apr-03 3:01 
GeneralRichTextBox - tab size Pin
Jucovschi Petru30-Apr-03 2:11
Jucovschi Petru30-Apr-03 2:11 
Generaldates in C# Pin
Andy H29-Apr-03 23:26
Andy H29-Apr-03 23:26 
GeneralRe: dates in C# Pin
ChrisDM30-Apr-03 1:02
ChrisDM30-Apr-03 1:02 
GeneralRe: dates in C# Pin
Andy H30-Apr-03 1:22
Andy H30-Apr-03 1:22 
QuestionAnyone interested in high quality gif article? Pin
BigAndy29-Apr-03 22:59
BigAndy29-Apr-03 22:59 
AnswerRe: Anyone interested in high quality gif article? Pin
Uwe Keim30-Apr-03 3:17
sitebuilderUwe Keim30-Apr-03 3:17 
AnswerRe: Anyone interested in high quality gif article? Pin
J. Dunlap30-Apr-03 8:20
J. Dunlap30-Apr-03 8:20 
AnswerRe: Anyone interested in high quality gif article? Pin
Jesse Squire7-May-03 11:54
Jesse Squire7-May-03 11:54 
GeneralTo access methods on a different form Pin
ajkumar29-Apr-03 16:55
ajkumar29-Apr-03 16:55 
GeneralRe: To access methods on a different form Pin
Stephane Rodriguez.29-Apr-03 23:18
Stephane Rodriguez.29-Apr-03 23:18 
GeneralSerializing and Deserializing objects through to a web service. Pin
Andy Davey29-Apr-03 14:46
Andy Davey29-Apr-03 14:46 
GeneralBufferedStream & StreamReader Pin
Katalyst29-Apr-03 14:10
Katalyst29-Apr-03 14:10 
GeneralRe: BufferedStream & StreamReader Pin
Katalyst29-Apr-03 15:59
Katalyst29-Apr-03 15:59 

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.