3 ms·
Can someone give an example of a blog post that gives example code yet warns "not to do it in production"? I've programmed and read about programming for decade
by crazygringo 8y ago
Can someone give an example of a blog post that gives example code yet warns "not to do it in production"? I've programmed and read about programming for decades and can't recall ever seeing anything like this.
It's hard for me to take this article seriously without even a single example -- I can't tell if this is a strawman or not.
Is it about code that isn't thread-safe? That relies on undefined behavior? That doesn't scale? That has race conditions?
"In dev" and "in prod" can mean so many different things (is it about scale? or running on different OS's? or running unattended? or running on different hardware? or running compiled?), out of any particular context they're essentially meaningless, and in case particular case, it would seem to be the particulars that matter...
- thinkingemote 8y agoFirst result from DDG. https://blogs.msdn.microsoft.com/canberrapfe/2013/02/16/powershell-web-access-very-quick-start-yep-powershell-in-your-web-browser/ https://blogs.msdn.microsoft.com/canberrapfe/2013/02/16/powe... the thing in that example is that a thing is not properly configured but good enough to get started with in development. Second result: https://stackoverflow.com/questions/1475297/phps-white-screen-of-death https://stackoverflow.com/questions/1475297/phps-white-scree... describes how to put debugging statements in the code which is good for local development but which shouldnt be kept for production.
- ISL 8y agoI searched for "don't do this in production". This article was the first hit, and several blog posts with example code followed.
- reificator 8y agoI've seen it dozens of times, and dozens more read articles where they should have. The entire Supercharged playlist on Chrome's Youtube channel does this, for instance.
- bartread 8y ago> It's hard for me to take this article seriously without even a single example -- I can't tell if this is a strawman or not. I felt similarly: it just rang slightly false to me. For one thing, a code review wouldn't be the first solution I'd reach for when diagnosing the kind of problems described (performance issues, memory leaks, random crashes). There's plenty of tooling available for most platforms that will generally get you to a solution more quickly and reliably (granted, the post mentions only spending half a day), and often highlight problems you might easily miss in a code review. I'm not saying code reviews aren't useful, but that measurement of real-life behaviour can be more useful in these circumstances. Still, the point about not copy-pasting code directly from the internet is well made: been bitten enough times over the years that I've become extremely wary of it, even - and perhaps especially - when in a hurry.
- rlucas 8y agoI recall seeing it many times (and ... mostly sometimes heeding the admonition). A lot of times you’ll see a solution snippet with inadequate exception handling or resource cleanup (file handles, dB handles, etc.). I’ve also seen a lot of regex examples that show a principle but don’t handle edge cases. See as canonical... email validation.
- mojuba 8y agoJust recently, been looking for code samples on how to send APNS (old-style) push notifications in PHP. Every single blog post or SO answer had such a low quality that was barely usable at all, let alone in production. Ended up writing my own implementation that has been pretty reliable so far, but the learning curve and the distance I travelled from those code samples on the Net seems pretty big now. On warnings though, I vaguely remember some warnings in a few places, but others seemed confident that they had the production ready solution (they didn't).
- deleted 8y ago[deleted]
- addicted 8y agoI’ve seen A few tutorial style posts with disclaimers like that. Usually when you want to illustrate a specific point using code, and the stuff you would naturally do in production (such as cleaning up memory or closing IO handles) is excluded since it’s a distraction from the point the author is trying to make. I know I’ve included a disclaimer like that in an internal presentation I had done in college and I’m pretty sure I did not come up with the idea myself.
- empath75 8y agoYou see it a lot in kubernetes tutorials.
- jacobsenscott 8y ago"Do not do this in production" is always implied. Blog post code is always chopped down for readability. There is no proper error handling, architecture, performance considerations, etc. Blog post code is for presenting concepts. It is up to you to write production quality code.
- stordoff 8y agoI've seen it plenty, e.g. Django: "This method is grossly inefficient and probably insecure, so it is unsuitable for production." https://django.readthedocs.io/en/latest/howto/static-files/ https://django.readthedocs.io/en/latest/howto/static-files/
- mattnewport 8y agoI've seen it plenty, what I don't ever recall seeing is a book or article that says "this is how you should do it in production". Generally there is just some hand waving over important other stuff like error handling you should take care of in a real system. I've also seen lots of production code that doesn't look that different from the code examples you shouldn't use in production. From my experience of real production codebases, the difference is mostly in accumulated bug fixes, which may or may not be documented but often make the code less clear and in lots of logging and debug code in parts of the code base that are particularly bug prone. If I was a cynic, I'd be tempted to conclude that we don't actually know as an industry how to write "production code", all we know how to do is write non production code and then try to patch it up until it kind of works in production.
- Volt 8y ago>Is it about code that isn't thread-safe? That relies on undefined behavior? That doesn't scale? That has race conditions? It can be any of those. Not a blog post, but one example that immediately comes to mind as something you shouldn't use in production is the [Redis KEYS command](https://redis.io/commands/keys https://redis.io/commands/keys).
- boomlinde 8y agoI've seen plenty of C code examples that made disclaimers about forgoing error handling. That said, I can't think of any off the bat.