This does happen a lot, but have you ever had the opposite happen? Where you go into some of your older code, and not only is it nice to read, but you had anticipated that you'd have to make this change later, and so the design makes the change easy?
That's happened to me a few times and all I can say is that it takes days for my self-satisfaction to wane.
This actually happened to me last month. I had to touch code from a previous team/project I was on.
I got the call for a collaboration/consult. I forgot everything about it. Jumped in a meeting next day anyway. We pulled up the code. Everything was documented and I had a section with parameters for a "wish" feature that they actually wanted finally. I pointed it out and told them the needful to finish the feature.
Happens more often the better you get at your craft. I used to say that if you don’t hate the code you wrote last year, you’re not improving. Well, let’s just say I finally stopped hating mine.
I am beginning to suspect that 90% of programming memes are made by beginners and 90% of the engagement with them is also from beginners. Maybe I'm just projecting. I remember seeing this stuff when I was starting and just assuming that must be how it is.
I am usually quite pleased with my old code. It ain't perfect, but it's doing well for itself. Sometimes there is silly stuff I need to fix, but then I just laugh at myself.
As soon as I stopped trying to write textbook OOP stuff, this stopped occurring to me. That was years ago.
I'm not saying I write perfect code, no. But when I read bad stuff I wrote, I can understand it and think of ideas about how to improve it if that becomes necessary.
On top of writing more functional-style code, the way I achieved this was:
Absolutely no inheritance whatsoever. Composition + interfaces work wonders for what I do.
Minimal mutable state. This pays dividends when debugging.
Ditto for type-system-encoded nullability markers (ie. ? in C#, std::optional in C++...)
I avoid writing code just-in-case something happens. If I haven't run it manually or via unit tests, it goes to the garbage bin (not an absolute, just a guiding principle). There's a chance that code isn't even correct to begin with and you'll have to throw it away should you ever need it.
Low indirection. I don't want to jump through 10 functions to see what something is doing, and nobody else does either.
I looked at code I wrote about a year ago today. Yeah, there are things I would've done differently now, but I had no trouble following it. Some of the choices I made were company standards at the time as well which, thankfully, have improved.
Depending on the state of sleep deprivation and flow state, even waking up to the previous nights code is an out of body experience of shock and awe. Either I am surprised at the level of complexity and elegance with the rabbit hole that I went down or it’s a fragmented mess of FIXME placeholders that don’t communicate the brilliant ideas and plans from past me.
Also the face almost everyone makes when they open up that tupperware that's been in the very back of the fridge for the same amount of time as your code.
39 Comments
BillyClark@piefed.social · 74 pts · 228d
This does happen a lot, but have you ever had the opposite happen? Where you go into some of your older code, and not only is it nice to read, but you had anticipated that you'd have to make this change later, and so the design makes the change easy?
That's happened to me a few times and all I can say is that it takes days for my self-satisfaction to wane.
Landless2029@lemmy.world · 12 pts · 228d
This actually happened to me last month. I had to touch code from a previous team/project I was on.
I got the call for a collaboration/consult. I forgot everything about it. Jumped in a meeting next day anyway. We pulled up the code. Everything was documented and I had a section with parameters for a "wish" feature that they actually wanted finally. I pointed it out and told them the needful to finish the feature.
Then I had a nice 5pm Scotch.
siipale@sopuli.xyz · 2 pts · 227d
Sir, don't redeem the code
Meron35@lemmy.world · 4 pts · 228d
CanadaPlus@lemmy.sdf.org · 4 pts · 227d
I had this happen recently. Very satisfying.
I did add some more comments and change names, though, since stuff I thought was obvious at the time wasn't totally.
AdamBomb@lemmy.sdf.org · 4 pts · 228d
Happens more often the better you get at your craft. I used to say that if you don’t hate the code you wrote last year, you’re not improving. Well, let’s just say I finally stopped hating mine.
jjjalljs@ttrpg.network · 3 pts · 228d
I used to be better at math and coding. If I pulled up my old project euler solutions I'm not sure I'd understand them anymore.
Sanctus@anarchist.nexus · 53 pts · 228d
Who the fuck wrote this!?
''Written by Sanctus Two/Months/Ago''
DmMacniel@feddit.org · 35 pts · 228d
someone must have tampered with git history!
molten_boron@sh.itjust.works · 20 pts · 228d
https://github.com/jayphelps/git-blame-someone-else
sik0fewl@piefed.ca · 8 pts · 228d
I stopped using git blame for this reason.
darklamer@lemmy.dbzer0.com · 27 pts · 228d
mfed1122@discuss.tchncs.de · 12 pts · 228d
I am beginning to suspect that 90% of programming memes are made by beginners and 90% of the engagement with them is also from beginners. Maybe I'm just projecting. I remember seeing this stuff when I was starting and just assuming that must be how it is.
SchwertImStein@lemmy.dbzer0.com · 16 pts · 228d
Junior ass meme
SaharaMaleikuhm@feddit.org · 14 pts · 228d
I am usually quite pleased with my old code. It ain't perfect, but it's doing well for itself. Sometimes there is silly stuff I need to fix, but then I just laugh at myself.
hdsrob@lemmy.world · 10 pts · 228d
2 months.
I've been writing the same software since 2003.
Someone left some real crap in there.
Guttural@jlai.lu · 9 pts · 227d
As soon as I stopped trying to write textbook OOP stuff, this stopped occurring to me. That was years ago.
I'm not saying I write perfect code, no. But when I read bad stuff I wrote, I can understand it and think of ideas about how to improve it if that becomes necessary.
On top of writing more functional-style code, the way I achieved this was:
?in C#,std::optionalin C++...)zeezee@slrpnk.net · 9 pts · 228d
I like that this meme implies women and enbies write immaculate code and never regret what they've written before 😎
tiredofsametab@fedia.io · 8 pts · 228d
I looked at code I wrote about a year ago today. Yeah, there are things I would've done differently now, but I had no trouble following it. Some of the choices I made were company standards at the time as well which, thankfully, have improved.
Otiz@sopuli.xyz · 8 pts · 228d
*his own two months old code
prettybunnys@piefed.social · 8 pts · 228d
Their
NichEherVielleicht@feddit.org · 5 pts · 228d
Good point...
Old version:

itsathursday@lemmy.world · 7 pts · 228d
Depending on the state of sleep deprivation and flow state, even waking up to the previous nights code is an out of body experience of shock and awe. Either I am surprised at the level of complexity and elegance with the rabbit hole that I went down or it’s a fragmented mess of FIXME placeholders that don’t communicate the brilliant ideas and plans from past me.
kubica@fedia.io · 7 pts · 228d
That's why I let my code rest for 2 months before committing.
diemartin@sh.itjust.works · 6 pts · 228d
TWO MONTHS!?!?
I don't even know what I did last week!
YurkshireLad@lemmy.ca · 2 pts · 228d
You and me both! Weekends are very disruptive these days!
Kolanaki@pawb.social · 6 pts · 228d
Also the face almost everyone makes when they open up that tupperware that's been in the very back of the fridge for the same amount of time as your code.
bleistift2@sopuli.xyz · 6 pts · 228d
You store your code in the fridge? Does that keeps the bugs out?
Kolanaki@pawb.social · 7 pts · 228d
Yeah, but things still sometimes freeze.
Goldholz@lemmy.blahaj.zone · 5 pts · 228d
Its a great to see how much i've improved in 2 years :)
Remembering the code i used to write and how i do it now
rebelsimile@sh.itjust.works · 5 pts · 228d
Eh. I just jumped back into a project and felt kinda like a fish getting back into water.
damnthefilibuster@lemmy.world · 5 pts · 228d
See, this is why vibe coding is awesome. You’ll never have to look at the code ever again!
YerbaYerba@lemmy.zip · 4 pts · 228d
When I git blame after finding the production issue and see the committer is me
mintiefresh@piefed.ca · 3 pts · 228d
I barely remember anything I made from 2 months ago lol
LillyPip@lemmy.ca · 3 pts · 228d
But… document your code.
Hahahaha for who?!?
Uh… for future you!
Me to future me: lol no
Rhaedas@fedia.io · 6 pts · 228d
"I'll remember THAT, it's such a trivial thing."
orbitz@lemmy.ca · 2 pts · 228d
Sometimes I do....most times I'd have preferred better comments but by now I can rewrite it better anyways. So no need for further comments....
Rhaedas@fedia.io · 1 pts · 228d
Oh no...
TomMasz@piefed.social · 3 pts · 228d
Arrrggghhhh! It's hideous! Make it go away!
hperrin@lemmy.ca · 2 pts · 228d
You mean… yesterday’s code.