News for hackers. Stuff that matters.
Re:We don’t have time for code reviews by mabbo on Wednesday October 23, 2013 @09:42AM (#6598630)
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.

Re:We don’t have time for code reviews by dlitz on Wednesday October 23, 2013 @12:53PM (#6599963)
To 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.

Re:We don’t have time for code reviews by joeblau on Wednesday October 23, 2013 @10:14AM (#6598833)
My 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.

Re:We don’t have time for code reviews by yxhuvud on Wednesday October 23, 2013 @11:29AM (#6599313)
They 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.
Re:We don’t have time for code reviews by joeblau on Thursday October 24, 2013 @08:26AM (#6604805)
Yep, 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.
Re:We don’t have time for code reviews by martinvanaken on Wednesday October 23, 2013 @09:52AM (#6598695)
This one should be recorded on http://www.codingconfessional.com/
Re:We don’t have time for code reviews by junto on Wednesday October 23, 2013 @10:17AM (#6598851)
As 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(){};
Re:We don’t have time for code reviews by myke_cameron on Wednesday October 23, 2013 @10:24AM (#6598894)
I 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.

Re:We don’t have time for code reviews by benihana on Wednesday October 23, 2013 @09:56AM (#6598736)
I 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."
Re:We don’t have time for code reviews by junto on Wednesday October 23, 2013 @10:14AM (#6598831)

   "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(){};
Re:We don’t have time for code reviews by xymostech on Wednesday October 23, 2013 @11:17AM (#6599228)
What about

  window.alert = function(){};
Re:We don’t have time for code reviews by jcromartie on Wednesday October 23, 2013 @10:11AM (#6598812)
Professionalism 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...