back

by yen223·14y ago·view on hn ↗
"An appealing theory that gets frantically upvoted may have well-understood but non-obvious drawbacks."

I'm reminded of the quote, "To every problem there is a solution that is simple, elegant, and wrong." I have fallen into the trap of looking at a long, messy piece of code, thinking "I can do better than this". I would replace a 50-line code with 5 lines, only to have it fail at some random edge case, which the original has been fixed for.

That is why I always remain skeptical of people who are out to "disrupt" an industry, especially when they don't have much experience in that industry.

2 comments
While often you do get rock solid code that is ugly and just works. there is nothing to say that elegant code can't solve all the problems and do it in a more readable and maintainable way. When I started transition my coding style form a imperative/OO base to a more functional base I found that you can get many elegant solutions that handle edge cases and are maintainable by designing a solution instead of growing one.
Cant remember where I read this, but I realized a while back the folly of "rewriting your code". Your code looks messy because it works. Its the result of weeks of testing and bug fixes. It can handle special cases and is robust.

Many a times, to start of, a clever 5 or 10 lines would suffice. But the moment you start testing it for production, it'd require more and more logic to handle _all_ the cases.

I think this is very common with new simple magical frameworks / languages too. They work really well for most common tasks but can't handle the edge cases.
I'm pretty sure you're referring to a Joel Spolsky article, "Things you should never do". http://www.joelonsoftware.com/articles/fog0000000069.html
Excellent post, thanks for the link.
Don't rewrite, refactor!