Raymond Lewallen

A few things .Net, a few things Sql

<August 2008>
SuMoTuWeThFrSa
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456


Navigation

General

Subscriptions

Post Categories



Monday, December 13, 2004 - Posts

Coping with Burnout
Eric talks about burnout on this blog post, and I hope to see quite a few more comments about it. No doubt, burnout hits each and every developer at one point or another. Its tough to deal with. We all do so much reading, writing, typing, reviewing, discussing etc that its easy to get burned out on it. Being a developer is very hard on a person's mental state over a period of time, it you have to get away from it. I would love to see some more comments on how people deal with avoiding and recovering from burnout. I've only had to seriously recover once, and it involved dropping an ongoing contract of 3 years, and lots of alcohol. This, my friends, is not the way to recover from burnout. How do I avoid it these days? I play with my daughter, I play my guitars, and I play Enemy Territory online with my friends. You'll notice the word play in each of those. Do something you enjoy every day that doesn't involve work. I enjoy my work, yes, but you have to do other things you enjoy too. Make time for the other things that make you who you are.

posted Monday, December 13, 2004 5:48 PM by rlewallen

Performance Issues with exception handling
An often discussed topic in the developer world is the performance of handling exceptions. Some argue that exception handling is too expensive. Yes, there is a performance hit when handling exceptions, but when you look at what you get out of exception handling, in my opinion, that is much more important and outweighs the fact that there is going to be a performance hit associated with the exception handling.

A big plus in the world of .Net and exception handling is the garbage collector. Managed code has its objects stored in the managed heap, and the garbage collector takes care of the managed heap for us. When we create objects in our code and then throw an exception, we know that the GC is going to eventually clean up those objects. Managed code compilers don't have to keep track of this information at compile time like some other compilers, and this helps out with the performance. The wonderful little Finally block in managed code allows us to clean up some of these resources ourselves, even. An unmanaged code compiler (unmanaged C++ is the best example) has to know what's going on with its objects. When an exception occurs, all the deconstructors for these objects must be called for all the objects that were created successfully prior to the exception. There is a lot of tracking going on there with the compiler, and it increases code size and creates a performance hit in order to handle all of this in unmanaged code. Managed code, thankfully, the compiler doesn't care anymore. Managed code compilers know that big brother GC will clean up any mess that gets made along the way, making our code smaller and probably (I haven't tested this yet, and honestly probably won't) performing better when an exception is thrown, given certain circumstances, than the same code written and compiled with an unmanaged code compiler. The reason I probably won't test this is because the JIT and your platform can greatly impact the performance of exception handling. Code JITted for an Alpha processor is going to perform differently than code produced for an x86 processor, and I don't have the resources to do all the testing necessary to get solid numbers. Just take my word for it, exception handling is worth any performance hit you might incur, so implement exception handling.

What's the alternative to exception handling for you skeptics? You write code to check the input values and return values of each one of your methods and pass a return value back up to the caller. This in itself is quite a performance hit, not to mention a coding and maintenance nightmare due to all the extra code that has to be written to do this. You also introduce more possible points of failure, which quite honestly, you need to wrap in Try blocks to handle an exception that may occur in your custom i-don't-like-exceptions-they-are-too-expensive-i'm-going-to-do-it-my-way code. Why do all that when it can be handled with a simple Try..Catch..Finally...End Try? I would have thought this argument would have gone away by now, but I still hear and see it lingering around. In my opinion, use exception handling and use it out the wazoo, where appropriate. What you gain is far better and more important than what you lose.

Exception handling is a very deep and diverse topic in managed code. Most managed code books probably have an entire chapter devoted just to exceptions. I encourage you to pick up one and read about them, if you haven't done so already.

posted Monday, December 13, 2004 7:54 AM by rlewallen




Powered by Dot Net Junkies, by Telligent Systems