But what price my soul?
Yes, it compiled. It worked even. Not only did it work, but it completely meets the client's requirements. But somehow when I look at those particular lines of code (16 lines, in this case, with DataGridGirl's help) I wonder about the ramifications of this horrible algorithm on my immortal soul.
If you know me, or maybe even if you don't, you know that it has been said I have an overdeveloped sense of smell. Specifically, Code Smell. Often it's a gift and has served me well. Other times it's a crushing weight as the schedule looms and I just have to buck and, well, write some crap. (Of course, if it is totally with in spec, performance, it works, QA, etc, it's not crap, but you know.)
So my question to you, fair readers and fellow codesmith's, how bad do you feel when the pattern doesn't quite fit or that nested foreach/foreach/foreach nested a bit to deep?
When do you know to let go? Some might say, “when it passes the NUnit Test!” Others, who look at coding as much an art form as science might disagree.
I noticed a number of folks, from Don Box to Doug Purdy, at the PDC making GREAT PAINS to let the audience know that “this or that particular line of code is an abomination! Look away, look away from these alpha bits that hold all our pride and all our shame.” I had to say I agreed with their evaluations.
What to do when you've built a great monument, but there's bird poop at the top that you're responsible for. Does it take away from the accomplishment?
About Scott
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.
About Newsletter
// this works, but I would like to refactor it
// must be a cleaner way to write this code
or
// this may look horrible, but IT WORKS.
// I call it my '72 datsun pickup code
At the same time, the reality is that most, if not all of us, live in a world of limited time and other limited resources, and it's not always realistic to make one's code ideal in either form or architecture. So I think sometimes, "good enough", assuming that it really *is* good enough, needs to be the answer. I'm sure that there's some code out there that I've written that I would not be proud to have made public. But as you say, if it meets the specifications, performs acceptably, etc., then it's doing what it's supposed to, even if it's not the most elegant code possible.
My 2 cents.
http://thetechnologist.is-a-geek.com/blog/PermaLink.aspx?guid=760a2825-38e6-4bf2-a35c-5f9ecfa2bf51
I think that every coder always thinks they can re-write every line of code to be a little cleaner or more efficient ; Practical coders realize there is a point where you HAVE to release the code. You just have to balance the quest for perfection with the need to ship. It helps to realize that all programming is basically hacks and work arounds to little quirks and bugs in your chosen platform.
Comments are closed.