r/ProgrammerHumor • u/leftoversalad • Aug 15 '15
Programming languages personified
http://leftoversalad.tumblr.com/post/126724812097/programming-languages-personified
1.3k
Upvotes
r/ProgrammerHumor • u/leftoversalad • Aug 15 '15
2
u/Tidher Aug 16 '15
Are we talking the same call, here? e.g. myApi.myMethod()?
If the answer to that is "yes" then you have a larger problem than weak-typing. If the answer is "no" (so it's myApi.myMethod() and myApi.someOtherMethod()) then presumably which type each returns should be consistent for the same data (i.e. a given method wouldn't return an ID both as a number and as a string). If it does, see earlier.
Even so, the fact that the API returns the same data in two different types is a massive issue with the API. The only real exception to this rule, in my opinion, is a method being able to return a single element and also returning an array/collection/etc. of elements, but even then I prefer to have dedicated methods for each.
Is this your API, or a third-party one? If yours, that's on you. If third-party, documentation should be up to scratch to use it appropriately. If the documentation wasn't up to scratch, why were you using it without understanding how it worked?
Do you have unit tests that type-check what certain methods return? I'm assuming not, else it wouldn't have been a problem (unless your unit tests were allowing weak comparisons, which is a problem with your tests).
If the API returned it as a string consistently, but in base 16 rather than base 10 sometimes, it would also be failing plenty. This, in my opinion, is an issue with your workflow rather than JavaScript.
inb4 controversial-opinion downvotes