Daddy, why did it take you 3 hours to write 4 lines of JavaScript?

Writing good code is not about how many lines you deliver in a day, it's about the quality of those lines.

The Confident Logo, Drupal Agency led by Mark Conroy

Nora Barnacle: How was your day, Jim?

James Joyce: Great.

NB: Did you get much work done?

JJ: Yes, lots.

NB: How much?

JJ: One word.

That's a pretty famous (probably apocryphal) story about Nora Barnacle asking James Joyce how much work he got done while he was writing Ulysses.

One of my daughters asked me recently how was my days' work that day. I said it was good. She asked what did I do. I said I spent about 4 hours writing 3 lines of JavaScript. She was astounded. How can it take you a half a day to write only 4 lines of code? So I explained it like this...

Imagine you are a plumber. You get called to an apartment because there's a leak. You have a look around, see there's water marks on the ceiling and verify that there's a leak. Well, that's the same as a developer. A client says they have an issue, you take a look and verify that there is an issue. That's the easy part.

Next the plumber needs to figure out where the leaking water is coming from. So he does a bit of poking around, moves some things out of his way, whatever else he needs to do to locate the source of the leak. He figures out it's coming from a pipe in the floorboards in the ceiling. The developer does the same thing, comments out some code, adds some debugging statements, switches off some caches, figures out where the issue lies. 

Now comes the hard bit for our plumber. Remember, the fault is in an apartment. There are other apartments upstairs, downstairs, and both sides of this apartment. He can't easily get at what he needs to get at. And all the water systems are linked together, so he doesn't want to do something that will affect another apartment. Guess what? The developer is often in the same position. I know there's a problem, I know where it's stemming from, but I've got to consider all the other applications and processes that rely on the piece of code I need to fix.

The plumber eventually figures out that if he has a long enough wrench, he can reach the thing he needs to tighten to stop the leak. He adds an attachment to his wrench, positions it where he needs it, and turns off the leak. It takes him 10 minutes. But he's been in the apartment for 4 hours. Well, that's what the developer also does. Figuring out the correct few lines of code needed to solve the problem can take an amount of time. It's not the amount of code that you produce that counts. It's the fact that you fixed the problem without introducing other ones.

 

Filed Under:

  1. Frontend Development