Hacker News new | ask | show | jobs
by zeroq 428 days ago
JS aside, I recently tried my very best to introduce proper logging and error handling to otherwise "look ma, no handlebars" codebase.

Call it a thought experiment. We start with a clean implementation that satisfies requirements. It makes a bold assumption that every star in the universe will align to help us achieve to goal.

Now we add logging and error handling.

Despite my best intentions and years of experience, starting with clean code, the outcome was a complete mess.

It brings back memories when in 2006 I was implementing deep linking for Wikia. I started with a "true to the documention" implemention which was roughly 10 lines of code. After handling all edge cases and browser incompatibilites I ended up with a whooping 400 lines.

Doing exactly the same as the original lines did, but cross compatible.

3 comments

I guess I’ll ask, did you try using exceptions?
> We start with a clean implementation that satisfies requirements ... Now we add logging and error handling.

If error handling and logging isn't necessary to satisfy requirements, why bother with them at all?

Handlebars like on a bike, or like the templating language?
They mean the bike analogy