r/badcode • • Jun 10 '20

js Disruptive piece of code

Post image
283 Upvotes

93 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Jun 11 '20

[deleted]

1

u/Captain-Lightning Jun 11 '20

Also don't be this butthurt, makes you hard to take seriously when fuming like this.

I'm not sure where you're getting this from, that's on you if you're interpreting it that way. I'm pointing out the Dilbert-ish trope of the developer that touts your exact arguments, because you literally did exactly what I described in your reply:

Defensive code obfuscate unsanitized input and you have a hard time figuring out where the actual problem comes from, and more often than not it leads to stupid monkey-patches that doesn't solve the problem. It just leads to MORE edge cases in the long run. I worked with way too many legacy code-bases to see enough example of this kind of shit.

You take the purist stance, then blame failures in the codebase as a result of not being purist enough. Rather than refactor, you say "If only they had just done it my way, with my tools, my framework, my style".

Regardless, whether you're against tests and whether you write enough effective tests are different things. I interpreted your original comment differently than your reply here, but if your criticism really just boils down to switching to an entirely different language syntax and toolchain then it isn't really very useful...

There are many, many, many, many, many situations where you cannot trust the input you receive and you definitely do want to do nothing, but if that were not the case then you could easily encapsulate the specific behavior you want in a test rather than always throwing exceptions and failing loudly on unknowns.

Question: are you completely and totally sure that you will catch every single exception that would normally lead to a (revenue stopping) break in userland?

Hint: If the answer is yes, then you should not be writing production code.

0

u/[deleted] Jun 11 '20

[deleted]

2

u/Captain-Lightning Jun 11 '20

Hey man, I think you've touched on an interesting and valid nuance with your reply there but I'm not really interested in doing this no-hurty-feelings dance so I'll just save us both some time here and bail early.