Live data from Hacker News

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

news.ycombinator.com

161–170 of 267 posts

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

#161
post #101

I've always loved seeing recursive functions I wrote in the past. The amount of power and elegance that can come from a good recursive function is my favorite.

hear! hear!

For me it's the opposite, I'm truly proud of those times where the obvious recursive solution is avoided and I manage to solve it with a "while(..){}". I'd be like "LOOK I DIDN'T TOUCH THE STACK ONCE". I'm raised on microcontrollers though.

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

#162
post #156
post #96

Earlier quoted context omitted.

100%. It's amazing how many GitHub repos have little to no comments, not even file or function overview comments. The amount of time save by potential contributors reading and having to interpret the code is way longer than it would take for the author to write the comments in the first place. To each their own, but comments are generally a positive addition to code.

I find it's not useful to have comments in code that you are actively working on since they quickly get out of date. They are best added when one finishes work on a block of code.

I get the feeling, but I rarely think "I'm completely done now, time to comment!" Better to admit that and document a bit earlier than when it's "finished".

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

#163
post #98

I've had the joy(?) of working for a company for close to 10 years, moving on to other work for about 5 years, and then returning again. During my first tour with the company I built, among other things: - (on a two-person team) an ASP.NET web app that allows payroll admins to extract year-end data from their AP in order to distribute tax forms (W-2s, 1099s, etc.) - (different two-person team) a mail-room management…

They're lucky (or cursed) to have had the same person build so many different systems at the company.

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

#164
post #43

I do sometimes go back and stare at this wonder I crafted once: s=>s[0]+/.*( .|z)|...s.s?|T..|M[i-t]+|[AFINOUW][^o]v?|.*/.exec(s)[0].slice(-1).toUpperCase() It does something pretty useful, that has surely been written many times over. But unlikely ever as succinctly as this. :)

Alright, I'll bite - what does it do?

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

#165
Just to continue the analogy about carpentry / home construction. About a decade ago when I moved into my apartment it came with a wall mount for the TV that had a tricky mechanism that would not be clear to a casual user how to mount/unmount from quick looking. And it would be even more difficult to figure out with a TV in the way.

10 years later, it's time for me to move out, and I'd left the TV as the last thing because I had forgotten how to work the mechanism to get the TV off the wall (and it would require all sorts of annoying face-against-the-wall maneuvering to see how to unscrew, etc).

I look from the floor up behind the back, and what do you know -- I'd left myself a taped note, extra bolts, and instructions on exactly where to turn the hidden lock screws (in the state where the TV already mounted) to release the unit from the wall.

I was marveling at my foresight for a self-satisfied minute (and thanking my past self).

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

#166

I don't code, but I do write. I regularly re-read my own writing to spot any problems, but sometimes just for pleasure. For example, about 18 months ago I wrote a 5 part series on how to build a direct conversion receiver for the ham radio bands from scratch. I learned tons along the way and it was really rewarding to write. Re-reading it recaptures some of that joy and reminds me that I'm a good writer, even when I…

If it captures you back then yes, your writing is so good that it doesn’t get in the way, you don’t even notice it. I am not a natural writer and have to always make an effort to make something sound the way I want to. Quite often I cringe at my old scribblings and that sometimes without a reason..

Oh I have plenty of those moments too!

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

#168
post #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.

Comments should explain the "why" and not the "what".

The code _should_ explain the what just fine, but it doesn't explain the problem the code is trying to solve at all. If you struggle to explain the why with a docstring or few comments, then that's a sign you didn't decompose the problem enough.

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

#169

Everyone's talking about code, but I do this with carpentry. Right now, I'm working as a trim carpenter in residential construction, and I pride myself on doing as good a job as I can. As a result, when I come back to a job to install door hardware after everything is painted, I sometimes just wander around the house and admire my work. Especially tricky details that took a bit of thinking to get right, even if no-on…

How does one find a trim carpenter (or any skilled tradesman) who has this level of attention to detail? There's definitely two tiers of work, someone who cares and work good enough for a rental unit, and you have no idea what you're going to get until it's done.

I've noticed good trades people always take pictures of their work. I'm now wondering if it's worth asking to see images of their recent jobs.
Post reply on HN