What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 133 Stack Exchange communities.

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?

share|improve this question
5  
For anyone's information (I had to look it up myself), the pros and cons of the using namespace std; directive are discussed on SO stackoverflow.com/questions/1265039/using-std-namespace –  Bill the Lizard Sep 26 '09 at 1:18

3 Answers 3

up vote 1 down vote accepted

Just edit the question.

share|improve this answer
    
I'll certainly do that when I have enough rep on SO. –  quamrana Sep 27 '09 at 7:04

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

share|improve this answer
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 Sep 25 '09 at 21:02
    
Maybe make a suggestion in the your answer then? –  Rowland Shaw Sep 25 '09 at 22:03

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.

share|improve this answer
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. –  David Thornley Sep 25 '09 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 Apr 6 '10 at 0:24

You must log in to answer this question.

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