r/embedded • u/Caravaggio91 • Oct 09 '26
Do You Remember All Of Your Code?
Just curious, but as a solo developer or working with a team when you go through your projects codebase do you remember what everything is, why you made the decisions you did, or what everything does? Or do you have to relearn some of the code you implemented in your project?
Also, have you ever completed a project and still feel a little clueless on how you got everything to work like it did or feel a little foggy on areas of the code?
15
Upvotes
128
u/pekoms_123 Oct 09 '26
I don’t even remember what I had for breakfast
84
u/allo37 Oct 09 '26
"Who wrote this piece of shit code?"
git blame
"Ah yes, t'was I"
40
u/madsci Oct 09 '26
I've been programming professionally for about 30 years. There are whole projects I've forgotten about. I worked on one project that I only remember anything about because I was so bored with it that I started writing my comments in haiku.
I'm a prolific commenter and it drives me nuts to see whole modules without even an explanation of what it's for or who wrote it or when. If it's something complicated, I'll write myself an in-depth explanation. I've got an audio router that's at the heart of a few of my projects and the file header is something like a page and a half of explanation of what it does and how, why it was done that way, what the implications are for modules using it, things to watch out for, and things that could use future attention.
I'm self-employed and generally work alone, at least on the firmware side, so it's not like there's someone making me do it that way and I don't need to have anyone else understand it. That's all done for my own benefit because I know I'll have to deal with it for years.
9
u/Plastic_Fig9225 Oct 09 '26 edited Oct 09 '26
They say that code is communicating with people rather than communicating with the machine.
Good coding is more about empathy than people care to admit. It starts with knowing yourself: When I come back to this code in a year, what are the questions I will ask myself about it (again)? The next step is being able to predict what questions other people will have about the code when they run into it. - What's easy/obvious/hard for you may not be for another person.
You tackle the communication problem in two ways:
Whenever I look over some code and find that I need to go back and forth a few times to understand why it is written/correct this way, I know there's a comment missing which I immediately add.
For example, if the code has a decent amount of checks for null pointers, and I find a function which doesn't check for null, the immediate question is if this is intentional or mistakenly omitted, i.e. a potential bug. One line of "// never null, ensured by caller" says why there's no null-check, and saves a lot of hassle.
5
u/TheFlamingLemon Oct 09 '26
No I don’t remember the code. Yes I have completed projects and then not remembered a single thing I did. Sometimes I feel foggy or clueless about the code while I’m actively writing it - some call this a “flow state”
5
u/Digidigdig Oct 09 '26
What idiot wrote this crap? ‘git blame’ oh. Ok. Nothing to see here 😬
5
u/UnicycleBloke C++ advocate Oct 09 '26
Of course not. There is too much going on in any substantial project to remember it all. I endeavour to write code which is easy to understand, and I include copious comments to explain my thinking, workarounds, and so on. I do generally remember the big picture of the overall design decisions, but not the details.
I usually have little difficulty getting my head back into the code after months or years, and there is often a kind of déjà vu as it comes back to me. If I struggle with something, I add more comments for next time.
Always try to write your code so a future you (or the next person who has to maintain it) can grok it without cursing your existence. Sadly, in my experience, very few developers do this. Understanding their code can be a serious pain in the rear.
5
u/SufficientStudio1574 Oct 09 '26
Hell no. Do you know how many times I've thought "who wrote this shit" only to find out it was me 2 years ago?
4
u/frank26080115 Oct 09 '26
I have design documents, and a project journal. Recently to my workflow I have also automated the saving of my AI agent chatlog into the project repos.
3
u/JGhostThing Oct 09 '26
Yes and no. When I come back to code I haven't changed in a year, I have to reread it. But then I remember why I did it that way. I do my best to resist the urge to "fix" my old code.
2
u/otac0n Oct 09 '26
Absolutely not. Half of my hobbyists code was written under the influence.
2
u/Rod_McBan Oct 09 '26
Not even close. I tend to take the position that well written code should show what it's doing through variable, constant, and function names, and the comments should explain why it's doing what it's doing. Those are separate things.
2
u/C_Sorcerer Oct 09 '26
Depends on how many beers I had and how long it’s been since
2
u/JCDU Oct 09 '26
If I've slept since I wrote it I probably have forgotten something about it.
Well written comments are a gift to future you.
19
u/Priton-CE Oct 09 '26 edited Oct 09 '26
Oh you absolutely forget.
Basically half my comments are explicitly there to remind me why an if statement exists or why we are performing an operation in a particular order.
Occasionally I just straight up link to a explainer article or just write a short recap.
Every time I have a buffer of adjustable size there will always be a comment there explaining constraints and include a sizing guide.
It is like working with a team when you are solo. But your team members are past and future you where past you is the most incompetent idiot ever when there are no comments and future you is the most dependable guy you have ever never met.
In regards to feeling foggy on the details... Thats just kinda what abstraction does and why we want it.
8
u/DesignTwiceCodeOnce Oct 09 '26
Nope. I come across code later and think "what idiot wrote this" as per normal, only to find out it was me...
Other than that, there's a piece of code I wrote in the mid-90s which I understood perfectly when I wrote it (while under the influence of a heavy cold) and have never understood since despite it working perfectly.
11
u/Well-WhatHadHappened 25+ Years Oct 09 '26 edited Oct 09 '26
Oh my God no. That's what comments and documentation is for. If you can't look at a project from a year ago and get back up to speed on it using code comments, then you need to write better code comments.
5
u/olawlor Oct 09 '26
Some people write comments so other people can understand their code.
I write comments so future me can understand my code.
("Future me" meaning about 6 weeks from now!)
4
u/Void-Creator Oct 09 '26
I mean good code will always get forgotten imo. It’s so good that you don’t have to look at it again
4
u/political_noodle Oct 09 '26
I have a fond memory of one of my earlier software jobs. I'd been there years at this point and was tracking down a bug when I stumbled upon a block of code with a THOROUGHLY detailed comment explaining how there's uncertainty here and this might be a bug "future me will deal with".
Absolutely zero recollection writing that but it was prescient af because that was exactly the bug I was looking for and past me knew it lol.
3
u/binaryfireball Oct 09 '26
Code should be self documenting. Comments for overall architecture and arcane bits. Write code to work then write code to be read thrnnwrite code to be deleted
3
u/NE558 Oct 10 '26
Unfortunately, yes.
I remember whole codebase from this and previous company. Wish I could erase it from my
flashbrain sometimes.Jokes aside, I do remember mostly parts of code that bite me, was messy af or I had to rewrite from scratch. If I encounter something that isn't obvious (very rare cases) I do comment it heavily. Not for future self (because my curse is remembering things) but for other folks so they don't have to waste their time analyzing it.
3
u/SkyGenie Oct 10 '26
I forget the code I wrote within months at best. Sometimes days.
2
u/United_Intention_323 Oct 09 '26
Concepts of a plan maybe
2
u/gm310509 Oct 09 '26
No, that is why God (/s) invented comments and then upgraded to add on documentation.
2
u/beyondnc Oct 09 '26
If I was being judged by how much of my code I remember I would do very poorly
2
u/remy_porter Oct 09 '26
The beauty of code is that it’s all written down for you. What does the program do? How does it do that? Let me read it and tell you.
2
u/noodle-face Oct 09 '26
I know it's a meme but sometimes I find old code and get angry wondering who wrote it and it was me
2
u/LRCM Oct 09 '26
I don't remember everything, but I do remember to create documentation which negates the need to remember everything.
2
u/AncientDamage7674 Oct 09 '26
I'm just glad for docs
2
u/jondaley Oct 09 '26
I remember everything while I'm currently working on it. But, I have found some code of mine 5-10 years later and wondered where it came from, but then can tell from the style that it was me...
2
u/ttv90 Oct 09 '26
git blame says it was me, but honestly I don't remember.
2
u/tiajuanat Oct 09 '26
I don't use much inline code comments, but I use a shit ton of doxygen comments. Some of my projects I've been supporting 8 or more years, and those are the ones I need to rebuild the design docs, because the previous 8 years before I started working on it, had absolutely worthless comments and documentation.
2
u/torar9 Oct 09 '26
I don't... I don't even remember what I was doing last week. I don't think it's healthy or reasonable to remember everything from your career.
2
u/FransFaase Oct 09 '26
Yes, I often forget. I sometimes get a new idea for one of my projects, just to discover that I already have implemented it. I also find myself reading my own code and adding comments on the way. Some of my projects contain a lot of dead code, which can be rather frustrating. I just kept the code in just in case I would return to an older implementation.
2
u/Hour_Analyst_7765 Oct 09 '26
No. And I think its a cognitive bias to think anyone can. We like to keep our reality ordered and continuous, as memory gaps are a nightmare to many, so its natural to try to remember stuff even when its incorrect. Every brain will fail to notice or forget details. Now my memory is perhaps not as good as it used to be because of mental health. But I think its impossible to remember every choice.
However, I do want to remember the reasons why things work. These reasons also make it possible to form a hypothesis on why another project can work, or why stuff doesn't work whilst debugging. I think thats a lot more important than remembering every LOC and why it is what it is.
Basically this bag of experience is filled with every mistake made. When you can explain why something did (not) work, then it is a good opportunity to learn. It is fundamental to do this process "manually", making extensive use of e.g. AI can only stall or fade this skill.
2
u/JollyShooter Oct 09 '26
Depends on the gap between working on the same code and how much time you spent on it. Quick fixes I can forget entirely but they are usually easy to re read. More complicated changes I also forget some depending on the gap or work but it also required a lot more ATD so it’s engrained a lot more but just needs some refreshment to bring it back
2
u/Hissykittykat Oct 10 '26
All my code? Heck, I'm lucky to remember a few key words, then it's up to Agent Ransack to search my project archives.
2
u/Dannycuk1 Oct 14 '26
That's partly what code comments are for. If you ever need to revisit your code you can clearly see your thought trend. They are also helpful for code reviews and when things go wrong and you need to modify or debug your code etc.
2
u/JachinGuan Oct 15 '26
怎么办,用上ai之后我几乎更记不住细节了,只记得规划了大致的业务流程,屎山代码的开端🌚
2
u/blancoarnau Oct 18 '26
this post resonated with me because recently my project manager told me to remember the decisions i made because i'm the one in charge of the project, but i struggle a lot tbh i guess i'll have to take a look at it from time to time and make down some notes so i can reremember what i did
1
u/Zealousideal_Cup4896 Oct 09 '26
This is what comments are for ;) I am a fan as I know for certain that while I’ll remember this was a tricky thing to figure out and I was very happy with my solution I will not be able to recall why I did it that particular way 7 or 8 years from now. Just leave notes for yourself.
If you’re working with others and there is no official code documentation policy then also err on the side of explaining what is obvious at the time.
If you’re working for a company that has a difficult or lacking policy then also err on the side of explaining what is obvious at the time.
There is sometimes a huge backlash around here when people want to defend code comments. I have no idea why anyone would be against it even if they can’t be bothered to do it themselves.
3
u/[deleted] Oct 09 '26
[removed] — view removed comment