What is this?
Well, it was inevitable that my long stint of greenfield projects was going
to come to end at some point, especially since I’m in the consulting world. So
now that I’m starting to find myself working in some pretty scary code bases
fellow LosTechies dude suggested I start blogging about my experiences.
And since I’ve already seen many, many things that make me say “huh?” and, at
times, brings tears to my eyes, I figured I’d give this first post a number
(assuming there are many more coming).
Ok, so really this is just an opportunity for my fellow developers to
perhaps not feel so bad about the code bases they are working in, because maybe,
just maybe, someone else out there has it worse. (As I’m sure there are folks
who are forced to work in stinkier code than I…)
In order to make these somewhat useful, I’m making them all about the code.
Smells that I see, and hopefully some simple solutions for fixing them, leading
to more maintainable and readable code.
catch (Exception ex)
if (ex.GetBaseException().Message.Contains("You gotta know this just *feels* wrong!"))
// do something
This one definitely had me scratching my head. I can honestly say this is
the first time I’ve ever seen a conditional expression based on the actual
string message on an exception. Scary, is it not?
Of course the first way to correct this smell that jumped out at me was just
to simply create a custom exception and catch it in its own catch block.
catch (SomeCustomException ex)
// do something
What kind of smelly exception-related code have you seen and
Post Footer automatically generated by Add Post Footer Plugin for wordpress.