7 ms·
I once pushed un-reviewed code that contained alert("Fuck"); It made it to a single user who was testing it for me, on the other side of the planet. He spok
by mabbo 13y ago
I once pushed un-reviewed code that contained
alert("Fuck");
It made it to a single user who was testing it for me, on the other side of the planet. He spoke very little English, and for that I am grateful.
That was my last push without review.
- martinvanaken 13y agoThis one should be recorded on http://www.codingconfessional.com/ http://www.codingconfessional.com/
- benihana 13y agoI think it's hilarious (and typical) that the moral of the story is "I don't push without code reviews" not "I don't use bad words in test code."
- jcromartie 13y agoProfessionalism is for people who wear shirts with collars and have nice cars and families. You know, the kind of people who fund the kind of place where you can use bad words in code...
- junto 13y ago"I don't use bad words in test code." This is actually really important. We had this happen with a customer whilst UAT testing. The project schedules were under pressure and as a result the customer went nuts (rightly so) and we had to make some concessions to customer as amends. It isn't just curse / bad words. Equally as bad are comments like: "this was the customer's stupid idea not ours" Also, if you really have to output test stuff in the browser use console.log('message') and not alert('message'). Then for production you can always do this at the top of your main JavaScript include: var console = {}; console.log = function(){};
- xymostech 13y agoWhat about window.alert = function(){};
- joeblau 13y agoMy comments are more along the lines of alert("GOT HERE 1"); alert("GOT HERE 2"); alert("GOT HERE 3"); Not very helpful if someone else sees it, but also not profanity.
- yxhuvud 13y agoThey can be quite irritating for others though, especially if they happen during a loop so that the user will have to click past 40 popups to access something.
- joeblau 13y agoYep, you're definitely right! I'm working on stopping that irritating process and adding in great logging and controlling it via a log level of some sort.
- junto 13y agoAs I said in another thread, always use console.log('message') and not alert('message'). Then for production you can always do this at the top of your main JavaScript include: var console = {}; console.log = function(){};
- myke_cameron 13y agoI think a lot of people like using alert() for debugging because it posses execution. Of course, so do break-points / "debugger" statements. Git pre-commit hooks for alert are helpful since few and far between are the circumstances where an alert is actually wanted in production. While you're at it you can add one for whatever set of profane terms, if you roll like that.
- dlitz 13y agoTo avoid this sort of thing, I have an editor macro that puts a comment like this at the end of the current line: alert("Fuck"); // DEBUG FIXME(dlitz) You can't see it here, but the comment also includes a few trailing spaces. This way: - "FIXME" gets gets highlighted in my text editor - the whitespace triggers a git warning when committing - I can configure a pre-push hook that refuses to push commits to origin that contain "DEBUG FIXME" - I ever do accidentally push it, it's clear that the code was just there for debugging, and that I'm the person to talk to about it. I also use "git add -p" to do a hunk-by-hunk review of my changes before committing them. None of this is very hard or time-consuming, and I can't remember the last time that I accidentally pushed debugging code since I started doing this.