DEV Community

David Joseph Kamer
David Joseph Kamer

Posted on

6

The "Genius" Developer

You don't have to be a genius to develop software. Dev isn't about reinventing the wheel, even if it's fun. Just like almost everything else in life, there's a difference between what you want to do and what you should do.

Let's reinvent JSON.parse

Gene is a fresh out of college Computer Science genius. He knows all of the algorithms that any undergrad degree holder in Computer Science could ever be taught, plus a few more that he studies in his free time. Studying algorithms makes him feel like a genius, and rightly so. His IQ might be above 160, but that doesn't really matter right now.

Gene is starting his first job as a JavaScript developer. He's never really "done" JavaScript before, but how can it be that much different from his C and Assembly code? He thoroughly studied both in school. He knows the difference between a bubble sort and a quick sort, how difficult can JavaScript be? It's not even a real language after all.

Gene's first task on his first day is to make an ajax request to the company's API. Most of the code is already written. The senior developer, a college drop out who attended a coding boot camp, just copied some boiler plate from a previous project to help Gene get started.

Gene cracks his knuckles, looks at the code, and sees it print out

"{"foo": "bar"}"
in the console. Whoa, this is super easy. Now he just needs to store this in a JavaScript "Object". He thinks to himself how silly JavaScript is to have so few data structures. Piece of cake, he just needs to parse the string using a few regular expressions, and then recursively add the keys and values into an "Object".

8 hours after reinventing JSON.parse

Gene stretches and yawns. He's done. The work day is over. No longer will the object "{"foo": "bar"}" remain unparsed. He clocks out, feeling validated in his genius. "Pah! JavaScript, more like EasyScript!" His confidence reassures his fellow office workers that a real genius now works with them.

2 days after reinventing JSON.parse

Gene is called into his manager's office. He's mostly been in meetings over the last few days, reassuring everyone that he really is smart by talking about algorithms. The senior developer is sitting in manager's office. The manager closes the door behind Gene as he sits down. They both hold a somber expression, with the senior developer mixing in a unique blend of petulance and contempt.

Gene asks, "What's all this about?"

The manager responds, "Wait a second, we need to wait for HR."

The senior developer sneers and then hides it.

Karen from HR enters the room with a saccharine presence, "Sorry to keep you waiting! Let's begin."

Over the next hour the senior and the manager explain to Gene how his code has cost the company several million dollars. The code he wrote only parsed the key and value on the first layer of an object. After all, he only wrote it to parse "{"foo":"bar"}". The result was an endpoint that sold items for "[object Object]" dollars. Now this isn't only Gene's fault. "Why the hell is '[object Object]' considered 0?" Gene protested, but the protest didn't matter to the HR department, and the senor developer knew why and just smiled. He knew that the last genius they hired had crashed the whole system with an invalid type, he got the blame, and he added a default case.

HR didn't like that Gene said he knew JavaScript like the back of his hand on his resume and in his interview.

Gene was fired.

Gene went home and googled "parse JSON with JavaScript", found that JSON stood for JavaScript Object Notation, that there was a built in tool called JSON.parse, and then proceeded to cry himself to sleep.

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (0)

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay