Live data from Hacker News

Ask HN: Do you ever go back and admire a piece of code you wrote?

news.ycombinator.com

61–70 of 267 posts

Re: Ask HN: Do you ever go back and admire a piece of code you wrote?

#62
I've only been coding for a few years now.

Often I'm sort of irked by my old code.

But it is telling that from time to time I find some old simple code that was easier to read / change than I expected if only because I coded it so simply and in an iterative sort of way.

There's something to be said for being simple...

Re: Ask HN: Do you ever go back and admire a piece of code you wrote?

#63
Yes! Some code reflects what the requirements demand, including error handling, and no more. The design is elegant in that it abstracts properly, is very readable and extensible. Periodically, when I'm feeling down about my abilities, I look over this code and smile.

Often I look at my older code and recognize the stage of development as a coder that I was in. It's usually not cringe-worthy but it makes me pensive about how I would handle it now.

Another joy is when I find out that a module I wrote is being used extensively by other developers. Just recently I found out that a small, single-purpose function I wrote for my specific needs and deployed to our shared library, is fundamental to another team. They asked me about modifying it for requirements they have. The code itself wasn't beautiful but it filled a need and could be understood well-enough to modify by another. It made me happy all day.

And yes, other creative pursuits give me the same joy. Some practice sessions on my drums seem effortless. My ideas seem to flow regardless of the technical difficulty. Likewise, some dinners I make are chef-level tasty and get the desired "yummmm" from my wife and daughter.

Keep a memory of the times when your code makes you smile. Those memories pull you through the down times.

Re: Ask HN: Do you ever go back and admire a piece of code you wrote?

#64
post #62

I've only been coding for a few years now. Often I'm sort of irked by my old code. But it is telling that from time to time I find some old simple code that was easier to read / change than I expected if only because I coded it so simply and in an iterative sort of way. There's something to be said for being simple...

Going back and being annoyed with your old code means you've improved.

Re: Ask HN: Do you ever go back and admire a piece of code you wrote?

#65
My one particular stand out accomplishment was back in the Lumatic (RIP) days. We were a small app that provided pedestrian navigation in cities that included public transit. When we expanded beyond a single city we quickly learned we had to deal with timezones. The straightforward thing was to convert the times in each GTFS feed (the file containing scheduled transit times/stops/etc) to UTC. So I started digging into to the horrors of the tzdata format and spent a solid 8 hours looking into options there, hit a wall, tabled the project for a few days after which time an idea popped into my head: change the timezone for the process serving the city to match the timezone of the city. Sure enough, changing the TZ environment variable worked like a charm and unix did the rest.

Re: Ask HN: Do you ever go back and admire a piece of code you wrote?

#66
There have been a few times that I've really admired code that I wrote ... it happened way more often building embedded systems where I was short on processor cycles and memory.

But I'll also comment on the opposite (which I attribute to continually trying to improve my craft). Often when I look at code I wrote >6 months ago, I find something that I'd do differently today. Sometimes it's downright distasteful!

Re: Ask HN: Do you ever go back and admire a piece of code you wrote?

#67

What I like better is when you are bumbling through code you wrote a while ago trying to figure something out and there it is, a golden comment from past you, telling future you why you wrote shit this way. Usually it's some corner case or weirdness in an API you're calling.

It's unfortunate that the younger generation of coders took "comments are code smell" idealogy to heart and are actively against writing comments.

Re: Ask HN: Do you ever go back and admire a piece of code you wrote?

#68
Yes! I do! But they’re never the parts I think they’ll be. Sometimes it’s the simplest of things like a nice CRUD api that’s bounded and neat. Sometimes it’s a horribly complex system with well known trade offs and intricate guarantees. I love looking back and thinking “yea I got that right” or seeing an abstraction that’s stood the test of time (my six year old report query definition and data table responses in a reporting system is one concrete example I’m proud of, but I’d rename some fields for sure). I have a few of these that I’m so proud of if I really stop and consider it. On the flip side, the majority of projects teach me something that I wouldn’t do the next time, hence the common “old code sucks” trope. I think it’s important to recognise when something worked as much as when something didn’t. It’s these successes that give me the confidence to try things a little outside the box if I think it’s for the best.
Post reply on HN