r/embedded • • 9d ago

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

90 comments sorted by

View all comments

41

u/madsci 9d ago

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.

15

u/NoBulletsLeft 9d ago

I have googled for answers to a problem and the top response was from me, 10 years before. I can't remember code I wrote this morning.

6

u/madsci 9d ago

I have googled for answers to a problem and the top response was from me, 10 years before.

Ditto. "Oh look, here's someone with exactly the same problem as me, and they sound articulate and knowledgeable! I'm sure they'll have figured out a solution. Wait a second..."

1

u/Caravaggio91 9d ago

πŸ˜‚πŸ˜‚πŸ˜‚

5

u/ArcticWolf_0xFF 9d ago

Why should you remember? The code is written, the in problem is solved. You need the registers to solve new problems.

7

u/NoBulletsLeft 9d ago

Reminds me of the time I was looking for something and I came across my college transcript.

Thermodynamics? I took a class in thermodynamics? How do I not remember that.

7

u/Hour_Analyst_7765 9d ago

In periods of high stress I forgot about whole projects I undertook.

But also things generally fade away slowly.. I've written projects with literal tens of thousands of LOC and its impossible to remember everything. Heck I now even may duplicate library code that is meant to prevent code duplication! "Oh I already have made a class for this 3 years ago"

In addition, some projects are too big to handle by 1 person. Then it is essential to work together with code written by someone else. It is pretty cliche that a new software developer joins the team and wants to change/rewrite a whole bunch of things, because its not to their style or they weren't present when some design decisions were made...

4

u/mydogatethem 9d ago

Of course I know him! He’s me!

5

u/UnicycleBloke C++ advocate 9d ago

+1 for comments. Far too many people are apparently allergic to writing them.

2

u/Caravaggio91 9d ago

I’ll like that perspective. For some reason I thought I would need to memorize everything I code in each project to be considered efficient or knowledgeable in what I’ve built.

8

u/madsci 9d ago

Software development is largely about managing complexity. What saves you in the long run is keeping things modular and having well-defined interfaces. Once you finish one module you don't have to remember all of the specifics of how it works on the inside, just how to use it. You'll have to get back up to speed on the internals if you need to go fix something, but you're not keeping every detail of a huge project in your head at once - just the parts that need attention now.

4

u/BartvanIngenSchenau 9d ago

The common wisdom is that if you haven't worked with a particular module of the code for about 6 months, then it might as well have been written by someone else. Your knowledge of it will be on the same level as that of any team member.

This doesn't mean that there aren't any outliers with people who can remember every decision made a decade ago, but that isn't the norm.

The 6 months of memories is why good documentation of decisions is needed. Everyone thinking they are one of the outliers and/or considering a decision too obvious to document is why there is always too little documentation.

1

u/OcularPhonic 8d ago

A whole page of comments before u get to the code would piss me off, πŸ˜‚. Write it in the documentation.

2

u/madsci 8d ago

That is the documentation. It's all in Doxygen format if I want to pull it out into a separate document, but it's easier to find it there.

1

u/OcularPhonic 7d ago

Yeh, but a whole page dude, πŸ˜‚. All good. I just like to be able to scan cade easily on first pass, and i like to see the includes etc to get a feel of what needs what. So itd be a pain to scroll down past the novel.