4 ms·
There are places to ask the question "I think I need X. Is there a better solution?" But the answer to the question "How to do X?" really shouldn't include mor
by ballenf 5y ago
There are places to ask the question "I think I need X. Is there a better solution?"
But the answer to the question "How to do X?" really shouldn't include more than a passing reference to "Here's how to do Y." If X is impossible, then that is of course the answer.
And as others have indicated, the most frustrating scenario that happens over and over is that once the "How to do X" question is asked, you can never get an answer to that question if the original poster relents and agrees that what they really need is an answer to "how to do Y?".
- shawnz 5y agoImagine the question is something like "How do I concatenate these strings into an SQL query?" Would you be willing to be responsible for the fallout of answering that question any other way besides "use parameterized queries instead"? Do you really think that should only be mentioned as a passing reference?
- unionpivo 5y agoExcept that you sometimes have to anyway (not for parameters, but to have dynamic conditions, filters etc.) And since every question about such things get auto corrected to use parameters (which doesn't help, since it's something else entirely), You have millions of buggy self glued sql queries allover code bases. (but hey most of them are using parameters, so yay - progress)
- shawnz 5y agoIn those cases the best solution would be to use a query builder library like JOOQ, I still wouldn't be willing to recommend someone in that position builds the query by concatenating strings together
- ballenf 5y agoAbsolutely, yes. Someone has to write the parameterization libraries. That is, whatever abstraction layer you want to employ, in the end SQL queries are strings. And the passing reference to the potential misuse here can be a big bold statement at the top of your answer.