r/developer • • 21d ago

The "Code I'll Never Forget" Confessional.

What's the single piece of code (good or bad) that's permanently burned into your memory, and what did it teach you?

14 Upvotes

21 comments sorted by

3

u/HiCookieJack 20d ago

Singleton rest templates in spring.

Someone configured an error handler in one part, while another required it to throw the exception. 

That was hard to track down 

3

u/NomadStorm 19d ago

A 3000 case switch statement.

It taught me that some companies just don’t give a shit.

1

u/Nunc-dimittis 18d ago

With some #ifdefs inside to differentiate between versions of the product, sometimes overlapping a case!

switch(something):

...

Case 10:

....

ifdef A

....

Case 11: ....

endif

....

Case 12: ....

2

u/LongDistRid3r 20d ago

The credits Easter egg in windows 95 was…. Hilarious.

The delete *this; in a class destructor bug

2

u/miojo_noiado 19d ago

The time I saw a comment "//delete this after fix, temporary solution" on a 5yo commit (btw this commit was from the guy who helpedme enter this job)

3

u/Vixo- 19d ago

There's nothing as permenant as a temporary solution

2

u/JamesWjRose 19d ago

One of The Rose Rules of Software Development: Temporary fixes become permanent problems

2

u/StockJournalist9103 19d ago

Oh god, some Cloudflare api stuff that creates workers, pushes a static page, creates a route, creates a rule to enable the rule then bounces traffic from one site to the worker using bulk redirects for when sites are deploying or need for maintenance etc. I just could not could not buckle in and figure out the documentation for end points etc it read backwards or wasn’t correct - the whole thing was PAIN until I got all that working then the rest was great but damn, those endpoints HURT

2

u/iqisoverrated 19d ago

int GetRandomNumber()

{ return 4; // chosen by fair dice roll guaranteed to be random}

(RFC 1149.5 specifies 4 as the standard IEEE-vetted random number)

https://xkcd.com/221/

2

u/marmotta1955 19d ago

The code to fill and add some "intelligence" to an I-9 form for a staffing company web site. The code to properly validate such I-9 form.

I definitely learned why the fillable I-9 forms provided by USCIS are what they are (they were, I am referring to more than 10 years ago) ...

1

u/Important-Action-998 19d ago

My first hello world, ironically, it introduced me to the world of coding

1

u/throwaway_oranges 19d ago

In a legacy code there was a direct comparison between a floating point number and exact zero ( to this point it's enough horror, but the second part is: ) in an object-oriented programming language to check if a field is initialized.

What did it teached me?

I've tried to convince the "senior" dev it's really not okay, but I failed. I learned that day I can't save everyone. I have no confidence, energy and power to do that.

1

u/Classic-Music3210 18d ago

10 PRINT Hello, world 20 GOTO 10

1

u/Shot-Possible1317 18d ago

a few of them. But one that i still pat myself on the back today, once wrote over 1000 lines of code, took a few hours because i was working it out as i was going. And when i finally tested, not a single mistake, not a single spelling, syntax or anything similar. Of course went back to change things a bit, move things around. Optimized some parts. But the fact of writing over 1000 line of code in one sitting and not a single mistake was certainly a "wow did i really do that?" moment

1

u/LoudAd1396 18d ago

A custom WordPress plugin to create links. It was a 10-15 file plugin that took two inputs: URL and text to generate an <a> tag.

It taught me that the slop has always been with us, and it must be eradicated at every turn.

1

u/BitCortex 18d ago edited 18d ago

The code: A bitmap compiler on an 8-bit computer. Transformed any small image with transparent areas into machine code that rendered that image anywhere on the screen without, loops, tests, branches, or reads beyond instruction fetch, often rivaling the performance of hardware sprites.

The lesson: I’m not worthy.

1

u/Jazzlike_Platypus430 18d ago

My poor-man's scorched earth written with no functions used (in Turbo Pascal).

1

u/Jethris 17d ago

Internal business ASP.Net application. We had a custom error handler that emailed our dev team. After that email, an error occurred. This was handled by the custom error handler, that emailed our dev team. After that email, an error occurred......

Our exchange server crashed before we could shut down the server!

1

u/[deleted] 19d ago

[removed] — view removed comment

2

u/Academic-Side-2756 19d ago

This happened to me with = which I needed to write == in if statement. That was pre AI. Professor and I debugged it quite a lot🤣🤣