2

This question can apply to any computer language, but my example is C++.

Many questions (quite helpfully) supply sample code (which I can paste into an IDE and try), but use using namespace std; which is a very bad practice in many cases.

I am concerned that with so many questions including this bad practice, this will be seen as normal and just end up promoting bad practice all over SO and Google.

I think that there are a number of students coming to SO with real questions, but somehow having picked up a bad habit. We need to answer the valid questions, but promote good habits as well.

Do I need more rep on SO to be able to edit the questions?
Can questions with some tags be flagged with some warnings to the writer?

1

3 Answers 3

1

Just edit the question.

1
  • I'll certainly do that when I have enough rep on SO.
    – quamrana
    Commented Sep 27, 2009 at 7:04
6

When this happens and I think it's worthy of it, I just comment on the code.

For the specific issue of using namespace std;, many tutorial sites and even books, use it in their examples. It's simply a way to save time and space for examples. It's generally well understood that libraries and production code should avoid doing so.

2
  • 7
    Unfortunately, I don't think it's generally well understood that production code shouldn't use using namespace std;. It's well understood among people who are knowledgeable and well taught about C++, but there's a whole lot more people who don't know it's wrong. Heck, look at all the "void main()" stuff out there. Commented Sep 25, 2009 at 21:00
  • I just started a programming in C++ class and my (just released last year) book preaches about blindly pasting using namespace std; in it.
    – Earlz
    Commented Apr 6, 2010 at 0:24
1

this is what voting and commenting are for -- When you see a bad answer, whether it's unclear, doesn't solve the problem, or promotes bad practice, then you have the option to downvote -- you should also leave a comment to explain why you believe it to be bade practice too.

Of course, you could always leave an answer of your own that doesn't exhibit the same problems, and explain why you think it's a better answer

2
  • 1
    @Rowland: Its the questions I'm concerned about - mainly because they appear at the top of the page. It seems costly to downvote questions on a technicality - I might want to upvote the question because its a really good question.
    – quamrana
    Commented Sep 25, 2009 at 21:02
  • Maybe make a suggestion in the your answer then? Commented Sep 25, 2009 at 22:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .