Yesterday, an old article resurfaced on dotnetkicks.com about validating Guid strings. Several comments hinted at the possibility of letting the .NET Framework convert it to a Guid and catching the FormatException.
WTF !?
I must be very old-fashioned, because I am still very religious about (mis)using exceptions in normal application flow. Exceptions were designed for exceptional events, not for validating user input.
Even Microsoft picked up on that, because they added a bunch of TryParse() methods in version 2.0 of the .NET Framework.
In case you’re wondering if there are any REAL reasons for avoiding exceptions in the normal flow of an application, I’ll give you two:
- Exceptions are slow. Let me repeat: SLOW.
- When you are in a debugging sessions, and you told the debugger to break at the first exception (which is often done), you will know what I’m talking about.
This weblog is sponsored by The Vici Project.








