I've seen some software funnies in my time, in this on-going mini-series I'm going to be sharing them with you. These posts will all contain genuine code I've seen personally, in production systems, (or even code I've written myself) - I'll leave the guessing who wrote it up to you!
I'll hopefully highlight some "interesting" code I've found in systems, but also aim to show you that developers of all ages and levels of experience make mistakes/bad judgements from time to time. We shouldn't be embarrassed by these. Instead, have a chuckle and then get them fixed.
If you come across any you think are particularly hilarious, please let me know on Twitter and I'll feature them here.
#2 - Remember to remove testing assets from a codebase
A number of years ago, a developer I know extremely well (ok - it's me), was leading the development of a brand new front-end for a financial company. This new front-end broke away from the company's previous way of doing things and was designed, from the outset, to be highly interactive, pleasing to the eye and just a pleasure to use.
I'm a huge fan of making small prototypes in html/js files on my local machine and once I've proved the idea works, I'll transfer that code over to the real codebase. Unfortunately, sometimes it's just easier to create new features inside the codebase, due to different UI elements all interacting and not having to spend time replicating that complexity in the simple html/js file.
This was one of those times.
I was tasked to create a drag and drop "group system", where dragging 1 element on top of another, would create a "Group", with a new icon and upon clicking that group icon, you'd see a modal with both of the 2 items inside.
I had the main functionality written in a day or two, I just needed to test swapping the icon to that of a group. We were still waiting on the external design company to finish (and send over) the icons. So I improvised...
As is true with many developers, I struggle with naming things, and also, thinking of original content. I turned to Google and just started searching for images. I can't remember what lead me down this specific train of thought, but I'd always loved these games. I downloaded the following image:
Admittedly, it could have been a lot worse, on personal projects, when I'm frustrated at code not working, the `console.logs` tend to get more obscene and offensive. Sometimes I accidentally check in these comments/logs.
Anyway, I'd downloaded that lovely image of Sonic (I used to love the Sega Mega Drive games - yes, I'm old) and used it as the "Group Icon". In those days, we used TFS and the TFS Branching workflow is terrible, and slow. So we tended to not really create branches and just check everything into the same branch that we all worked on. Priorities changed and half-way through the work I was moved onto something more pressing. The group code remained in the code base, but during development/testing, was forgotten about.
Fast forward a month or two and the group work was de-prioritised, I moved onto creating other features and groups was forgotten about.The executive and sales team, were out to market, showing off our un-finished (protoype) application.
A random Tuesday morning, I arrived into work, sat down at my desk and booted up the laptop. One of the sales team, came to talk to the team, we asked about how the "Big Demo", that the company had spent weeks preparing for, it went great he said, apart from one minor detail. He'd forgotten about the ability to group, and the person controlling the demo application (on the big screen) had moved one icon very ver close to another, the system then (rightly so) decided that these should actually be in a group. Then appeared Sonic!
He admitted he looked very very confused, in front of the packed-room, full of execs and high-level business stakeholders (from global banks, you definitely will have heard of). The room laughed, and, unfortunately, because of the unfinished nature of the grouping system (and the combination of the auto-save functionality), he was unable to remove Sonic from his new home. So the next 20 mins was full of serious financial speak, 90's video games and a blue anthropomorphic hedgehog.
...Could have been worse - it could have crashed!
Let this be a lesson, don't use TFS!!!!!!!(or make sure you remove "testing-assets" from the codebase)