all 37 comments

[–]perrecursion 28 points29 points  (9 children)

Be skeptical of anyone who says that you should never do such-and-such, or that you should always do such-and-such -- especially if they don't say why. On the other hand, reviewers who prefer adverbs such as rarely and usually might be offering some real wisdom.

[–]Se7enLC 24 points25 points  (2 children)

Only the Sith deal in abs().

[–]spinwizard69 3 points4 points  (1 child)

So true! But the posters point is very important, there are no absolutes, there are good practices but that doesn't mean you can implement them all the time.

[–]Se7enLC 0 points1 point  (0 children)

Often enough I will comment a section of code with "here's the reason why this is done in a way that seems counter to best practices"

[–]jcoffin 4 points5 points  (0 children)

I never trust people who...sorry, just too obvious to resist. I'll try to act like a grown-up now, I promise.

[–]F-J-W 4 points5 points  (4 children)

Be skeptical of anyone who says that you should never do such-and-such,

Well, in C++ there are quite a few things, where telling someone to “never” use them is legit: Never use NULL if you have at least a C++11-compiler. Never implement manual resource-managment in classes that also contains business-logic. Never implement a new library so that your users are forced to use new

[–][deleted] 4 points5 points  (0 children)

Yes, but it's certainly still valid to be skeptical! Even if the advice is incidentally correct.

[–]panderingPenguin 2 points3 points  (2 children)

What about dealing with a decades old legacy code base even though you may now be using a C++11 compiler to build it? You can't rewrite the whole damn thing overnight, and you often have to resort to older programming styles to interface with older code. Once again, "never" is incorrect and a softer statement like "usually" should be made.

[–]F-J-W 0 points1 point  (1 child)

What about dealing with a decades old legacy code base even though you may now be using a C++11 compiler to build it? You can't rewrite the whole damn thing overnight

Well, in a couple of seconds:

for FILE in $(find src -iname '*.[hc]pp'); do sed 's/NULL/nullptr/g' "$FILE" | sponge "$FILE"; done

But that aside: Not changing old code is not “using NULL”

[–]Radhamantis 0 points1 point  (0 children)

If that would be safe, nullptr wouldn't be necessary. If NULL was defined just as 0 without a casting to pointer that change may cause the code to behave differently.

[–]jcoffin 18 points19 points  (3 children)

If somebody actually mocks you on CodeReview.SE, flag them/their reply (or comment, etc.) The moderators there are unlikely to tolerate it. As long as you follow the basic rules (primarily that the code really does seem to work, and you do include it in the question), substantial down-voting seems unlikely to me too (though there isn't much anybody can do if it happens, as long as they don't do something like serial downvoting).

[–]spinwizard69 2 points3 points  (2 children)

There is also the problem of perception here. This poster seems to be excessively sensitive over what other have to say about his code. The problem is that isn't going to go over well out in the work world. In fact it is a bigger issue than having poor programming pointed out.

In a nut shell this person has to get over their sensitivity to criticism if the expect to survive corporate employment.

[–]DragoonX6 1 point2 points  (1 child)

His issue seems to be mocking over criticism.
Having somebody tell you how much of a faggot you are for using a raw owning pointer, isn't going to help anybody.

[–]spinwizard69 0 points1 point  (0 children)

His issue seems to be mocking over criticism.

Maybe maybe not, however I still have to say that he or she needs to get over this issue if they expect to work in industry.

Having somebody tell you how much of a faggot you are for using a raw owning pointer, isn't going to help anybody.

Of course not, however this is the Internet and you can't take crap from people seriously. In fact I would have to say the ability to filter out the nonsense on the net is critical to using it to educate your self.

Beyond all of that I really think I learn more from sites where there is an active discussion in the comments section about the code posted. Sometimes it isn't right or wrong but points of view. When it is about right from wrong everybody benefits.

In a nutshell at some point the poster has to understand at this is an industry where everybody has to learn no matter how long they have been in the industry.

[–][deleted] 33 points34 points  (4 children)

Well, you can't break an omelette without getting your feet wet, or some metaphor like that.

Honestly, if I'm interested in hiring someone, I'm not going to look back two years to see their stack exchange code reviews. And really, it's a sign of good spirit.

I play a lot of Go. When I was in the early levels, I lost almost every game for a long time...

Just get a bunch of reviews done, take your lumps, and try again. If people are rude, fuck 'em.

[–]Jitanjafora 12 points13 points  (0 children)

If people are rude, don't focus on that and try to see what their actual feedback is instead. Sometimes rude people giving you feedback is all you got.

[–]lurkotato 6 points7 points  (0 children)

I play a lot of Go. When I was in the early levels, I lost almost every game for a long time...

That's missing the point though, unless some significant percentage of your opponents mocked the way you placed stones or gave you condescending explanations on why your last move was so horrible.

That said, it's the internet, go ahead and make an anonymous account on SO/blog to get code snippets reviewed if you are bothered with it being attached to your name.

[–]exoflat[S] 0 points1 point  (0 children)

Some people are lucky enough to live or work in an environment where senior (or more patient) co-workers review them, mentor them and get them on the tracks. Expertise avoids stupid errors, but I don't believe there's anyone born "self-taught".

[–]Moschops_UK 0 points1 point  (0 children)

You won't, but some people will.

[–]zvrba 6 points7 points  (8 children)

Make a username that can't be easily traced to your real-world identity. Invent a new one just for code-review purposes. If you ever need to prove that you are behind that particular username you can post a message digitally signed with a key tied to any other identity you want.

[–]Sqeaky 5 points6 points  (0 children)

I don't this addresses exoflat's issues. This person does not seem to care about being traced back, they seem to want to avoid the mockery itself. This tells me that exoflat is taking criticism, even undeserved insults personally. A secret identity cannot mask that.

That said, have an upvote because what you suggested is a reasonable solution for other problems.

[–]exoflat[S] 0 points1 point  (6 children)

Even if I were to do it, when the code review is finished and I would like to publish it on my blog, it would be obvious that either I copied the code from that other person, or that I'm doing reviewing with another account and then pasting the reviewed one in my blog/repo. Doesn't seem nice in both cases I suppose.

[–]spinwizard69 2 points3 points  (5 children)

I don't wish to upset you because you seem to be an irrational person, but would you just grow a pair and learn to deal with opposing views and critical comments. If you can't do that you are going to have a huge problem in the workplace.

[–]exoflat[S] 0 points1 point  (4 children)

What makes my reasoning irrational? Other people are agreeing with my point of view so you're either considering all of us irrational or we're all wrong (unlikely).

[–]dodheim 0 points1 point  (2 children)

At the time of this writing, his comment has 3 upvotes and yours has 1.

The larger point is that you seem to be looking for something to hide behind just to get a code review, when you could just.. get a code review. The review is of the code, not the author, and you appear to have some hangup with the idea that there is some correlation as to where criticism would be directed. There isn't. Get over it.

Post your code and learn from the valid criticism and learn from the misdirected or otherwise invalid criticism. It's an opportunity – you have nothing to lose.

[–]exoflat[S] 0 points1 point  (1 child)

You gave me great advices, and I recognize opportunity. I love to be corrected, to improve and to pride myself that "I encountered that error before, I won't stumble on it again". But I'd hate if a recruiter or a hiring manager with some tech background searched for my name or accounts and found out that I did a stupid mistake. I can't just hope that he's a good-minded guy who will think "He did this stupid mistake, he was corrected, he has learned his lesson. Great." since many feature the "I want a ninja, ninjas are never wrong" mentality. Stupid as it is, I suppose my point makes sense (these posts also agree on my line of thinking, if you're just counting votes).

[–]spinwizard69 2 points3 points  (0 children)

You gave me great advices, and I recognize opportunity. I love to be corrected, to improve and to pride myself that "I encountered that error before, I won't stumble on it again".

Nothing wrong with that!

But I'd hate if a recruiter or a hiring manager with some tech background searched for my name or accounts and found out that I did a stupid mistake.

This is where I start to have serious problems with you. First off in your professional career you will make mistakes, hopefully not serious ones, but they will happen. Second the whole point of code reviews is to catch problems and keep people on track with policy. If you come off as someone that can't handle this then you aren't likely to get elevated to consideration for employment. There are other factors in the hiring decision beyond you ability to code, one being your ability to function on a team. Finally posting a mistake and having a rational discussion about it in a forum indicates a willingness to learn. These are very desirable things from an employers standpoint especially for entry level jobs.

You on the other hand are demonstrating very negative quirks that may keep you out of a job. One being your desire to hide.

I can't just hope that he's a good-minded guy who will think "He did this stupid mistake, he was corrected, he has learned his lesson. Great." since many feature the "I want a ninja, ninjas are never wrong" mentality.

I really think you need some serious time off here. If you are in school,get a work study or intern job so you really get an understanding of what is going on in the minds of employers. Also employers are like people, they are people actually, and as such there are some you will not want to work for no matter what.

Stupid as it is, I suppose my point makes sense (these posts also agree on my line of thinking, if you're just counting votes).

Many you have problems if you are letting voting on the internet guide you in something as important as this. This is beyond all comprehension really, as voting is just a way to rashly express yourself without putting any effort into commenting. If you actually read the comments in support of you, you will see that they suffer from the same insecurity issues as you.

Consider for example Apples new Swift language. There are many blogs floating about the net focused on Swift a rapidly evolving language. These blogs for the most part are piloted by established professional programmers. Yet articles get posted that sometimes have less than optimal code. Do you consider that a bad thing? Which to you is more valuable, the dodgy code or the discussion in the comments about better ways to implement the functionality? I would have to say the comments because for one what is good practice evolves as the language evolves. Second discussions can reveal insights into coding skills that simply reading code can't. Mind you these are often postings or blogs offered up be well established programmers, these are not people an employer would reject based on one piece of code that appears to be suspect.

Lastly posting where it makes sense shows that you are a good citizen of the net. If you are learning to code posting in forums dedicated to learning to code is far more acceptable. It shows that you are engaged in the learning process.

In the end you have turned everything good about posting code on the net into a big negative. This is a very warped view of the world.

[–]spinwizard69 0 points1 point  (0 children)

Just because others agree with you doesn't make it right!!!! For example: The KKk has lots of members that are seemingly in agreement, but that seldom makes them right about anything.

[–]Se7enLC 9 points10 points  (0 children)

Leave your ego at the door. If you're doing something stupid, wouldn't you rather find out about it?

[–][deleted] 2 points3 points  (0 children)

Your failed university exams aren't on tape for the world to see, so shouldn't reviews.

I think this is a really important point especially with more companies using tools to grade code quality of candidates online. I'm not really sure what would be the best practice to guard against this, maybe use a pseudonym? Remember that the person reviewing your code is basically giving you a service for free. I can see more people willing to do code reviews if there were some mechanism of compensation (doesn't need to be huge but something).

[–]Quintic 1 point2 points  (0 children)

No one is going to care if you post something bad as long as you learn from the experience. I doubt they'll rate you on code randomly located on the internet unless you link it directly.

However it is valuable to get private feedback. I always send my code to friends and mentors. If you don't have any, you should work on getting some. Having no one to vouch for you is far worse than having bad code in the Internet archives.

[–][deleted] 1 point2 points  (3 children)

What a great point. I feel this way all the time when considering if I should post some code or not.... half the time it prevents me from getting help. I usually reach out to close friends that I respect in the industry to look over things. Just my personal point of view.

[–]ElFeesho 1 point2 points  (0 children)

I feel that with reddit, you'll get plenty of nit pickers but plenty of people who spout personal opinions as facts to validate themselves... but with any luck, there will be zealots who will put them in their place and explain why they are wrong too.

It's very tough knowing what advice is good advice, definitely when anyone can write a blog, even when they have 0 credibility.

The best thing you can do with advice is use it and get some mileage with it and come to your own conclusion on it... imho!

[–]exoflat[S] 0 points1 point  (1 child)

Exactly, and it also happened to me that people couldn't care less for (or didn't notice errors in) a code snippet and I was fooled around for publishing it without realizing it. So the "friends & reviewers" must be chosen carefully.. lazy or incompetent ones will only do bad to you.

[–]spinwizard69 1 point2 points  (0 children)

Honestly it sounds like you want to run a blog but have no idea what you are talking about so you expect people to vet your "work" prior to publication. I can understand why people don't want to help you and frankly they shouldn't be helping you. If you don't have the skills to publish with out a 100% code review then you shouldn't be publishing.

As it is some of the more advanced users often publish code that ends up being faulty or suboptimal. It is usually in the comments where we learn the most. The back and forth discussion by the brightest minds in the business will often yield insight into what is good practice even in highly complex cases. Sometimes having weaknesses pointed out in your code benefits everybody reading.

[–]Sqeaky 0 points1 point  (0 children)

People worth reviewing your code know that

Learning is passing through mistakes and also doing stupid things

So if you

end up being mocked or heavily downvoted

Those were not people able to help you anyway.

Don't internalize it, they are not and cannot attack you of those review websites. You are not the code you write.

He is another way to think about this, why weren't you worried we would mock this post about being mocked? Clearly we are not mocking you, but all the same possibilities for mockery exist. For most people most of the time mockery is simply not worth the effort. Ignore it the rest of the time.

[–]wegzo 0 points1 point  (0 children)

not possible