How to train yourself to avoid writing “clever” code?
Posted
by
Dan Abramov
on Programmers
See other posts from Programmers
or by Dan Abramov
Published on 2011-07-11T14:09:23Z
Indexed on
2012/08/28
21:51 UTC
Read the original article
Hit count: 660
programming-practices
|architecture
|language-agnostic
|code-smell
|considered-harmful
Do you know that feeling when you just need to show off that new trick with Expression
s or generalize three different procedures? This does not have to be on Architecture Astronaut scale and in fact may be helpful but I can't help but notice someone else would implement the same class or package in a more clear, straightforward (and sometimes boring) manner.
I noticed I often design programs by oversolving the problem, sometimes deliberately and sometimes out of boredom. In either case, I usually honestly believe my solution is crystal clear and elegant, until I see evidence to the contrary but it's usually too late. There is also a part of me that prefers undocumented assumptions to code duplication, and cleverness to simplicity.
What can I do to resist the urge to write “cleverish” code and when should the bell ring that I am Doing It Wrong?
The problem is getting even more pushing as I'm now working with a team of experienced developers, and sometimes my attempts at writing smart code seem foolish even to myself after time dispels the illusion of elegance.
© Programmers or respective owner