←back to thread

1070 points dondraper36 | 1 comments | | HN request time: 0s | source
Show context
GMoromisato ◴[] No.45069016[source]
One of the ironies of this kind of advice is that it's best for people who already have a lot of experience and have the judgement to apply it. For instance, how do you know what the "simplest thing" is? And how can you be sure that it "could possibly work"?

Yesterday I had a problem with my XLSX importer (which I wrote myself--don't ask why). It turned out that I had neglected to handle XML namespaces properly because Excel always exported files with a default namespace.

Then I got a file that added a namespace to all elements and my importer instantly broke.

For example, Excel always outputs <cell ...> whereas this file has <x:cell ...>.

The "simplest thing that could possibly work" was to remove the namespace prefix and just assume that we don't have conflicting names.

But I didn't feel right about doing that. Yes, it probably would have worked fine, but I worried that I was leaving a landmine for future me.

So instead I spent 4 hours re-writing all the parsing code to handle namespaces correctly.

Whether or not you agree with my choice here, my point is that doing "the simplest thing that could possible work" is not that easy. But it does get easier the more experience you have. Of course, by then, you probably don't need this advice.

replies(11): >>45069191 #>>45069245 #>>45069268 #>>45069600 #>>45070183 #>>45070459 #>>45072910 #>>45073086 #>>45075511 #>>45076327 #>>45077197 #
me-vs-cat ◴[] No.45076327[source]
> I spent 4 hours re-writing all the parsing code to handle namespaces correctly.

Wouldn't it have been less effort and simpler to replace the custom code with an existing XML parser? It appears that in your case the simplest thing would have been easy, though the aphorism doesn't promise "easy".

If using a library wasn't possible for you due to NIH-related business requirements and given the wide proliferation of XML libraries under a multitude of licenses, then your pain appears to have been organizationally self-inflicted. That's going to be hard to generalize to others in different organizations.

replies(1): >>45077245 #
GMoromisato ◴[] No.45077245[source]
Honestly, four hours spent programming is my idea of heaven.

I totally agree with you that most people should not implement their own XML parser, much less an Excel importer. But I'm grateful to have the luxury of being allowed/able to do both.

The specific choice I made doesn't matter. What matters is the process of deciding trade-offs between one approach and another.

My point is that the OP advice of "do the simplest thing that could possibly work" doesn't help a junior engineer (who doesn't have the experience to evaluate the trade-off) but it's superfluous for a senior engineer (who already has well-developed instincts).

replies(1): >>45077590 #
1. me-vs-cat ◴[] No.45077590{3}[source]
That's fair, and I also especially enjoy exploring "solved" problems when I don't have a backlog demanding priority.

Still, your experience with those holding "senior" job titles involves greater median expertise than I have found in my experience.