4 ms·
On the other hand, I'm only happy with a line of code that I wrote myself until the next time I look at it.
by psadauskas 16y ago
On the other hand, I'm only happy with a line of code that I wrote myself until the next time I look at it.
- koningrobot 16y agoIt is good to be humble, but better to be realistic. Why the parent's self-deprecating sentiment is so popular is beyond me. "I hate my own code" seems to confirm the "to each their own" view, but some ways of doing things really are objectively (but perhaps not measurably) better than others. When I write code, I write it as well as I can, and I will usually be happy with the result. Then I write more, and as the nature of the problem I'm trying to solve becomes clearer to me, I think of better ways to model the problem and the solution. Later, when I come back to the older code, I will rewrite it to fit the new style. I am not, at that point, unhappy with the old code. It was written with great care. The fact that I changed my perspective and will proceed to rewrite it with great care does not change that. I am unhappy with code on a daily basis, but rarely my own. I fully and proudly own up to this, and my intention to rewrite other people's code is not some kind of primitive urge to exercise my power. It's simply that most code isn't written with care or foresight at all. Those who write the code usually protest the rewrite with "why change it if it works?", but with that kind of thinking you might as well write everything in assembly. I write code with great care, and I imagine that all who do so would gladly accept suggestions for improvements. That's the kind of humble I think we should be shooting for.
- dagw 16y agoThe problem is that many people aren't given the time and circumstance needed for them to write code as well as they can. When a feature needs to be demoed on Friday morning for the large contract to be closed you do what needs to be done to get something that runs and promise yourself you'll fix it when you have time (yet knowing that that time may never come). You know what you did is objectively bad, but you know that to do it objectively better would take longer (probably because it would require you to fix some other rushed part of the code produced under similar circumstances).
- psadauskas 16y agoI'm always learning. When I come back to some code I've written before, I'm never happy with it because its missing an idiom that I learned in the meantime that would make it simpler. Or, I didn't completely understand the problem, and some of the assumptions I made at the time turned out to be wrong. Or, it's more complicated than it needs to be. Or, its too simple, and I need to add more functionality. Code is never finished, it's just released. Then modified, and released again. Then abandoned.
- Lewisham 16y agoExactly! My personal programming mantra is: "If you can come back to code you wrote two months later and like it, you're a bad programmer." Good programmers always see room for improvement. Bad ones don't know that their code is bad (and everyone's code is bad. Apart from maybe Knuth.)
- Dove 16y agoInverse for me. When I'm writing code, I'm never happy with it. I need to get a job done now and can barely spare the time to make it minimally presentable. It's always an embarrassment that I'm happy to abstract away as soon as I'm sure it's correct. But then, I don't spend a lot of time writing code. I spend most of my time reading other people's code, and most of it is . . . well, let's charitably call it mediocre. But occasionally, I'll come across a piece of code and think, "Hey, that's actually pretty good! Who wrote that?" Usually? It was me. Put another way, code that I write under duress to get a job done, I hate at the time. But later I am quite fond of it. Code that I write at a leisurely pace and to my satisfaction, I am proud of at the time. But later it looks naive and foolish.
- phaedrus 16y agoActually I sometimes come across old code I've written and think, "Wow that's really neat. I wonder who wrote this?"
- secos 16y agoexactly the same for me. Always wondering if there is a better way to write that line of code. My goal: 100% performance improvement (ie: there is no line of code)