Answers.Body: <p>I don't see why the same practices in the industry wouldn't apply to students. Professionals don't come pre-loaded with firmware to handle code-<em><strong>reviews</strong></em> :) Here's been some of my experiences both giving and receiving code reviews:</p>
  
  <ol>
  <li>Prove you're right if telling someone they're wrong. Making a baseless assertion up-front is equivalent to, "I told you so," until proven otherwise.</li>
  <li>Show how the code will break if you think it will break. Don't just spout rhetoric in favor of different way to do it.  </li>
  <li>Don't add your improvements to the list of changes needed. Keep necessary changes and improvements separate. If the coder likes your improvements, they will implement them. </li>
  <li>Appeal to their vanity by showing them how you can make their code even better instead of showing all its pitfalls. Learning new tricks is easier than losing bad habits.</li>
  <li>If you think something is wrong but you can't prove it, ask questions about its use instead of making assumptions. Even a solid educated guess gone-wrong can make a code review less constructive from that point on, and waste your time in the process.</li>
  </ol>
  
  <h3>edit:</h3>
  
  <p>Emphasis on code-<em><strong>reviews</strong></em>. <a href="https://cseducators.stackexchange.com/users/124/gilles">Gilles</a> brings up some good points when taking into consideration more in-depth criticism of code in the form of code-<em><strong>audits</strong></em>. These steps above are not the steps I would take for a code-audit.</p>
  
  <p>In regards to the main difference between the two and how to interact with people, I would say it has more to do with understanding the core intent of the code and figuring out where it falls short and coming up with more elegant solutions. For example, someone might accidentally re-invent something from C++11's <code>&lt;algorithm&gt;</code> library to help sort something from their class. In a code-review, I would mention this and advise you to remove it and replace it, but in an <em>audit</em>, I would <em>tell</em> you to fix it and remove the redundant code, because of the conversation's scope and the relationship's connotation.</p>
  
  <p>If I'm auditing your code, it's usually because of one of these reasons: </p>
  
  <ol>
  <li>It was requested ad-hoc for no specified reason   </li>
  <li>Critical/frequent problems originating from a certain module or modules too often   </li>
  <li>It was scheduled  </li>
  <li>It was requested by the dev   </li>
  </ol>
  
  <p>It's <em>usually</em> #4 and if you're playing with some fast and loose code cowboys, #2. So, in both of those scenarios you're basically the mentor/master and less of a peer. You're not there for the thumbs up/down, you're there to <em>take charge</em> and in some cases, <em>teach</em>.</p>
  
  <h3>edit 2:</h3>
  
  <p>Expanding on code audits and analysis as well as quality, I feel the living legend John Carmack does a good job describing it: </p>
  
  <blockquote>
    <p><em>The <strong>most important</strong> thing I have done as a programmer in <strong>recent years</strong></em>
    <em>is to aggressively <strong>pursue static code analysis</strong></em>. Even more valuable
    than the hundreds of serious bugs I have prevented with it is the
    change in mindset about the way I view software reliability and code
    quality.</p>
    
    <p><em>It is important to say right up front that <strong>quality isn't everything</strong></em>,
    and acknowledging it isn't some sort of moral failing. <em><strong>Value is what
    you are trying to produce</strong></em>, and quality is only one aspect of it,
    intermixed with cost, features, and other factors. There have been
    plenty of hugely successful and highly regarded titles that were
    filled with bugs and crashed a lot; pursuing a Space Shuttle style
    code development process for game development would be idiotic. <em><strong>Still,</strong></em>
    <em><strong>quality does matter</strong></em>.</p>
  </blockquote>
  
  <ul>
  <li>Original publication URL: <a href="http://altdevblogaday.com/2011/12/24/static-code-analysis/" rel="nofollow noreferrer">http://altdevblogaday.com/2011/12/24/static-code-analysis/</a></li>
  <li>Working "reprint" as on 2017: <a href="http://www.gamasutra.com/view/news/39328/InDepth_Static_Code_Analysis.php" rel="nofollow noreferrer">http://www.gamasutra.com/view/news/39328/InDepth_Static_Code_Analysis.php</a></li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-06T08:35:10.310Z
Answers.Text: If you use these practices in industry, you're making bad software. My experience is in security, where we take quality seriously — your industry may be more ok with bugs. There are many, many cases where useful review feedback is “I can't see a bug, but the way you're writing it is dodgy, you should write clearer code” (with specifics as to how it's dodgy and how to make it clear of course). This comes from experience, not from pointing out a specific defect. It should be up to the coder to prove their code correct, not up to the reviewer to prove it wrong.
Answers.UserDisplayName: Gilles 'SO- stop being evil'
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-06T17:56:08.990Z
Answers.Text: So your diverging experience makes mine "bad software"? While I appreciate your input on the matter, you're making generalizations from an admitted point of specialty. If you have to ask if other parts of the industry care about bugs less than security, I don't know what to tell you other than yes, the industry in-general is going to care less about bugs than the security layers, _naturally_, with few but notable exceptions. Lastly, it's the coder's _unit tests_ that proves their code works. CR is _not_ the place to prove your code works, but proves it passes muster.
Answers.UserDisplayName: kayleeFrye_onDeck
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-06T19:24:27.910Z
Answers.Text: +1 for "showing them how you can make their code even better"
Answers.UserDisplayName: Ellen Spertus
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-06T22:32:24.940Z
Answers.Text: @kayleeFrye_onDeck Unit tests prove that the code works *in some cases*, which is a far cry from the code working. I'm aware that some parts of the industry don't care about quality. I don't want to train the next generation of programmers in that spirit.
Answers.UserDisplayName: Gilles 'SO- stop being evil'
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-06T23:09:29.813Z
Answers.Text: While apathy can lead to bugs, the existence of bugs is not proof of apathy. I said they care _less_, not that they don't care, and yes, code reviews are _not_ where you prove your code works. Unit tests, integration tests, functional tests/sample apps, you name it; that's where you verify code _works_. If you're deep-diving the code for bug and security analysis, you're describing a _code audit_, not a code review. They're quite different in their scope of responsibility and depth of analysis.
Answers.UserDisplayName: kayleeFrye_onDeck
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-06T23:19:52.297Z
Answers.Text: Btw, I'm not trying to brow-beat you on the objective importance of quality in code. It's _very_ important, but it's not everything _all the time_. You work in security, so of course you'd be biased about it, and you can't help that easily. I wouldn't expect it otherwise. Medical equipment, security layers, aviation systems, weapons systems, automated vehicle solutions -- those things are life & death code, and that stuff gets its own umbrella of quality requirements well outside the normal bounds of responsibility of code quality. I would never discourage quality code.
Answers.UserDisplayName: kayleeFrye_onDeck
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-06T23:22:41.240Z
Answers.Text: And lastly, I usually take off kid-gloves for code-audits. There's no point in not pointing out flaws and vulnerabilities when someone requests in-depth analysis of your code. How I interact with someone during an audit is not the same as a review, so if I were to take your feedback and put in the scope of an audit, I believe we would be in agreement on the level of coverage and type of feedback returned.
Answers.UserDisplayName: kayleeFrye_onDeck
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-05T21:29:47.930Z
Answers.LastActivityDate: 2017-07-07T22:19:30.647Z
Answers.LastEditDate: 2017-07-07T22:19:30.647Z
Answers.UserDisplayName: kayleeFrye_onDeck
Answers.Body: <p>Don't actually do it. Often students code with time limits and/or when they are tired. This means that some implementations are done because they're faster to implement or because changing the current implementation would require too much time, or the student didn't even stop to think about other implementations.</p>
  
  <p>With that said, instead of giving a critique, provide a suggestion. Ask what led to that implementation, and (most of the times) they'll realize they could have done differentely in x,y,z. Then, ask what they feel about another implementation and its pros/cons and what could be used. </p>
  
  <p>If the goal is to have a student learn to code, help him get his thinking process in order, not his code.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-06T01:34:58.110Z
Answers.Text: I feel like you're drawing a distinction without a difference here, unless you define what you mean by these terms. Nevertheless, we are always glad to have a new voice join us here. Welcome to [cseducators.se]!
Answers.UserDisplayName: Ben I.
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-06T01:50:44.773Z
Answers.Text: I simply feel that the best way to learn is by 'learning' rather than being taught to. Exposing flaws and alternatives stimulates critical thinking and would hardly be considered offensive by anyone
Answers.UserDisplayName: Oak
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-06T01:27:44.550Z
Answers.LastActivityDate: 2017-07-06T01:27:44.550Z
Answers.UserDisplayName: Oak
Answers.Body: <p>To borrow from Agile practice, you can adapt a form of the 
   <strong><em><a href="https://martinfowler.com/bliki/PrimingPrimeDirective.html" rel="nofollow noreferrer">Prime Directive</a></em></strong>.</p>
  
  <p>Always lead with it before looking at the product/code/process. It can feel repetitive, and even elementary. So it helps to
  rotate the reader of the quote, and open it to team discussion with new members.</p>
  
  <p>Its value grew and became more appreciated every time a retrospective
  revolved around a significant incident/bug/crisis. It gets the team
  past <strong>blame</strong>, toward the mindset of self-improvement. Before learning the prime directive, I experienced the blame aspect of code reviews consistently.</p>
  
  <p><strong>Edit:</strong>
  Adding the <a href="http://www.retrospectives.com/pages/retroPrimeDirective.html" rel="nofollow noreferrer">quote here</a>:</p>
  
  <blockquote>
    <p>Regardless of what we discover, we understand and truly believe that everyone did the best job they could, given what they knew at the time, their skills and abilities, the resources available, and the situation at hand.</p>
  </blockquote>
  
  <p>The purpose as I understand it is to</p>
  
  <ol>
  <li>Create a <strong>Safe Zone</strong>. Nothing leaves the room. Eliminate fear.</li>
  <li>Treat the code as a product of the team, not one engineer.</li>
  <li>Action not attitude. Focus team energy on productive analysis and improvement</li>
  </ol>
  
  <h3>Feedback</h3>
  
  <p>As mentioned by Ben-I. In a lot of ways, code reviews are feedback (to the team). In feedback, there is an opening to achieve alignment.
   <a href="http://stoneandheen.com/" rel="nofollow noreferrer">Thanks for the Feedback p.232, Stone&amp;Heen</a></p>
  
  <blockquote>
    <p>The opening is important because it sets the conversation's tone and trajectory.</p>
  </blockquote>
  
  <p>and further</p>
  
  <blockquote>
    <p>You're not telling the feedback giver what they can or can't say; you're working to clarify the mutual purpose of the conversation and suggesting a two-way exploration. This helps you get aligned for the rest of the conversation.</p>
  </blockquote>
  
  <p>Also in feedback, both giving/receiving benefit from practice. In the same way it helps improve your speech delivery, Toastmasters utilize a Evaluator role to practice judging speakers. Have students practice <em>giving</em>, and <em>performing</em> code reviews.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-06T08:32:31.883Z
Answers.Text: You mean, start every review by “… we understand and truly believe that everyone did the best job they could …”? If I was at the receiving end of this, I'd feel like you were saying “you did a bad job, but it's ok, it's just because you're an idiot”. It doesn't get the team past blame, quite the contrary.
Answers.UserDisplayName: Gilles 'SO- stop being evil'
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-08T22:07:22.490Z
Answers.Text: > We see things not as they are, but as we are - Anaïs Nin, various
Answers.UserDisplayName: 杜興怡
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-06T03:12:34.803Z
Answers.LastActivityDate: 2017-07-08T22:06:35.380Z
Answers.LastEditDate: 2017-07-08T22:06:35.380Z
Answers.UserDisplayName: 杜興怡
Answers.Body: <p>I have always enjoyed the fact that as a programming teacher I have almost no need to invest time into building up authority (at least not when teaching young adults). Unlike many other fields we always have a computer at hand that will tell us about the mistakes we make, and as soon as we are talking about more complex topics like code design there is always an explanation why something is considered good or bad style.</p>
  
  <p>The result is that I don't see any need to express negativity in my code reviews. I know that good programmers will think of sub-optimal code as horrible mistakes, that's what drives us to improve our code constantly and not be fine with anything that works.
  But for students getting something to run and do what they want it to is often a huge achievement, not just subjectively but also objectively. If the code doesn't do what they want they will be open for suggestions anyway, so this question will most likely be about situations where the student may argue that "it's working, so why bother listen to your advice?".</p>
  
  <p>The solution I found for myself is to avoid arbitrary rules. Don't tell students what they "have to do" unless they actually have to do it in order to get something to run. Otherwise they will immediately see that what you are telling them is factually wrong, since they didn't do it your way and it still runs, so apparently they didn't "have to do" it.</p>
  
  <p>Instead try to illustrate the upsides and downsides of their solution and your alternative solution. In most cases it's easy to come up with a simple test that allows you to demonstrate the benefits of your suggestions. For example if it's about code design have the student rewrite a short paragraph according to your suggestions and then ask someone who doesn't know the code and wasn't involved in the conversation to summarize what the code does. Usually the improvement will be quite obvious.
  If your advice was good and you communicated it the right way the student will be proud that they were able to improve their code, since the whole demonstration revolved around the code the student rewrote and the reaction they got. You and your authority (i.e. the things that might trigger pride and make the student eager to prove you wrong) are out of the equation.</p>
  
  <p>If it's not about code design but about things like architecture illustrate it with a reasonable change request that would be more difficult to implement with the "bad" architecture you want to argue against.</p>
  
  <p>Of course tests like these will fail sometimes and the "improved" code will not work better, but if that's the case and you don't see a flaw in the way your suggestions were implemented, then this may actually teach you that your advice isn't as powerful as you thought it was, and reflecting that to the students in a mature way will even improve the respect the students have, because you are demonstrating that it's not you against them, it's all of you against the hard facts.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-05T08:03:14.747Z
Answers.LastActivityDate: 2017-07-05T08:03:14.747Z
Answers.UserDisplayName: Lars Kokemohr
Answers.Body: <p>Feedback can be intrinsically threatening, and people are open to feedback only under the right conditions.  Here is an <a href="https://open.buffer.com/how-to-give-receive-feedback-work/" rel="noreferrer">excellent article</a> that discusses the psychology of feedback.  In their summary, feedback can be received when:</p>
  
  <ul>
  <li>The feedback provider is credible in the eyes of the feedback recipient.</li>
  <li>The feedback provider is trusted by the feedback recipient.</li>
  <li>The feedback is conveyed with good intentions.</li>
  <li>The timing and the circumstances of giving the feedback are appropriate.</li>
  <li>The feedback is given in an interactive manner.</li>
  <li>The feedback message is clear.</li>
  <li>The feedback is helpful to the recipient.</li>
  </ul>
  
  <p>As for the classroom context, I believe that the two most important things have already been said by Peter and Buffy: keep the focus on the code, not on the student, and make sure that you have a warm relationship with your students.</p>
  
  <p>What little piece I would add would be that, <em>given the above</em>, if the things you are asking your students to do have self-apparent value, then the resistance never appears in the first place.  If they don't have self-apparent value, then asking the question "how can I make sure my students are receptive to what I have to say" is the wrong question, something more fundamental is missing in the presentation.</p>
  
  <p>My biggest victory in this regard was when I figured out how to teach about coding style.  I could not <em>for the life of me</em> figure out how to present it as something with intrinsic value.  The code that we worked on was all short enough that it hardly mattered, the kids were perfectly able to understand their <em>own</em> code, and my protestations aside, the kids couldn't see any good reason to put thought and effort into indentation, variable names, function names, clean organization, etc.</p>
  
  <p>I outlined how I eventually solved that problem <a href="https://cseducators.stackexchange.com/a/132/27">here</a>.  By the time I finally had it sorted out, the kids started to see <em>intrinsic value</em> to clarity in their code, so the suggestions I gave to help them achieve that end were no longer met with resistance.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-07T08:05:33.087Z
Answers.Text: your examples at the link here https://cseducators.stackexchange.com/questions/130/how-to-teach-why-indentation-is-important/132#132 are informative!
Answers.UserDisplayName: Philip Oakley
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-05T16:45:51.733Z
Answers.LastActivityDate: 2017-07-05T16:45:51.733Z
Answers.UserDisplayName: Ben I.
Answers.Body: <p>I have all of my students read <a href="https://docs.google.com/document/d/18e0zklTPKzMS9LkzUTIUGEYoMdt86U-Xjwcum5TABQw/edit#heading=h.ohrh5dps3opt" rel="noreferrer">Keeping Perspective</a>, a section of <a href="https://docs.google.com/document/d/18e0zklTPKzMS9LkzUTIUGEYoMdt86U-Xjwcum5TABQw/edit?usp=sharing" rel="noreferrer">So you want a code review...</a>, which I wrote when working on an open source project. It's short enough that I'll excerpt it here:</p>
  
  <blockquote>
    <p><strong>Keeping Perspective</strong></p>
    
    <p><a href="https://i.sstatic.net/nOhwy.png" rel="noreferrer"><img src="https://i.sstatic.net/nOhwy.png" alt="October 12, 2001 Hackles cartoon"></a></p>
    
    <p>I began working at Google when on sabbatical after having been granted
    tenure early at Mills College, where I had been working since becoming
    MIT$^3$ (SB, SM, and PhD).  As a professor, I had been the sole judge of
    others’ code.  I expected to sail through my first code review and
    hear that they had never seen such excellent code before.</p>
    
    <p>That’s not what happened.  To give you an idea of what did, here is
    the art that was created from my suffering, since reshared by many
    other Googlers:</p>
    
    <blockquote>
      <p><strong>The <a href="http://en.wikipedia.org/wiki/K%C3%BCbler-Ross_model" rel="noreferrer">Five Stages</a> of Dealing with a Code Review</strong></p>
      
      <ol>
      <li>Disbelief: "How could someone find so much to complain about in my code?!" </li>
      <li>Anger: "How dare someone suggest that a hash-map of hash-maps isn't an efficient way of storing data?" </li>
      <li>Bargaining: "Maybe if I add the comments the reviewer requested in one file, I won't have to fix the tricky Unicode issues in another." </li>
      <li>Depression: "There was so much wrong with my code.  How can I show my face to the person who reviewed my code?" </li>
      <li>Acceptance: "Wow, my code is a lot better due to the feedback.  This is a useful process, although I bet it's occasionally painful for everyone."</li>
      </ol>
      
      <p>It’s much better not <a href="http://abstrusegoose.com/381" rel="noreferrer">to take suggestions personally</a>.</p>
    </blockquote>
  </blockquote>
  
  <p>I also try to model an openness to feedback by soliciting suggestions on how to improve my teaching and putting them into practice immediately. (To see how well I succeed at this goal, I add this question to the end-of-semester evaluations: "The instructor responds well to and incorporates student feedback.")</p>
  
  <p>I begin code reviews by congratulating students on what they've accomplished and telling them I'll show them how to make their code even better (as suggested by kayleeFrye_onDeck).</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-06T19:58:08.687Z
Answers.LastActivityDate: 2017-07-06T20:08:23.643Z
Answers.LastEditDate: 2017-07-06T20:08:23.643Z
Answers.UserDisplayName: Ellen Spertus
Answers.Body: <p>Here a few techniques I use in my class when giving feedback on student code:</p>
  
  <ul>
  <li><p><strong>Use a rubric.</strong> CS50 has a clear grading approach: code is assessed along the four axes of scope, correctness, design, and style. Within style for example, I might focus particularly on readability vis-à-vis indentation. If a student is marked down on this item, she knows exactly what she missed and why she may have lost points. The clearer the criteria of evaluation, the better the student response to being assessed on said criteria. I also think it's valuable to share rubrics in advance. Only seeing it after the fact can make students feel like how they were being graded was being kept a secret, which can lead to resentment of feedback. </p></li>
  <li><p><strong>Avoid "you" statements.</strong> This is something I caught myself doing and tried to correct as the year went on. Let's say I'm reviewing a student's code, and I'm commenting on the naming of variables. I might be tempted to say, "<em>You</em> have unclear variable names here." That frames it as an assessment of the student, not of the code, which does not set the right dynamic. I try to make sure I say something like this now: "<em>Your program</em> has unclear variable names here" or "to improve <em>your code</em>, make <em>your program's</em> variable names more precise." The goal is give feedback on the code, not the coder, so language should reflect that focus. (Side note: with how personally code reviews can be taken, I think how we frame the language of assessment is essential to building proper classroom culture when it comes to grades and feedback.) </p></li>
  <li><p><strong>Reward revision.</strong> This one is possibly more applicable at the high school level, but I think it does matter in terms of building a culture of receptiveness to code review feedback. Allowing students to revise their work gave me the ability to see students improve their work based on my commentary. In my mind this is what education is all about: inspiring a continual learning process. The pragmatics will vary from context to context, but requiring some sort of revision or reflection or allowing students to "recover" some/all lost points communicates to them that at the end of the day, you want them to be better programmers. Grades take a backseat to learning. Again, this might make less sense for university students, but in my class this approach goes a long way in terms of students constantly working on improving their craft. </p></li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-05T11:05:32.347Z
Answers.Text: I agree, but you can go further. Instead of "Your program has unclear variable names here", try "_The program_ has unclear variable names here". Make it all about the program. Reward Revision is brilliant and should be a pedagogical pattern. But I'd dispute your "restriction" to secondary level. You can do it with doctoral students (imo) in their preparatory work. And "reward" can be more general than points.
Answers.UserDisplayName: Buffy
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-05T11:10:36.830Z
Answers.Text: The Embrace Correction Pedagogical Pattern is very similar to Reward Revision: "Give the student the chance to improve their artifacts."
Answers.UserDisplayName: Buffy
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-05T13:23:31.860Z
Answers.Text: I was also thinking that "our program" and what "we" might want to do might work
Answers.UserDisplayName: Michael Durrant
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-05T14:10:28.077Z
Answers.Text: @Buffy I'm amused that in the comment here, instead of saying "I agree, but this answer can go further" it says "I agree, but __you__ can go further." It shows how difficult it actually is to provide this sort of criticism!
Answers.UserDisplayName: enderland
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-05T16:19:05.677Z
Answers.Text: @enderland I'm amused by _your_ comment here. I think < opinion > that when you give positive advice and encouragement _you_ can use _you_ just fine. But I take your meaning, and thanks.
Answers.UserDisplayName: Buffy
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-05T18:40:08.247Z
Answers.Text: I might go one step further than **Avoid "you" statements**.  I think would I could recommend is to **use "I" statements**.  Say things like, "I am confused by this variable name".  This shows that the feedback is somewhat subjective.
Answers.UserDisplayName: sixtyfootersdude
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-06T00:34:05.243Z
Answers.Text: Another reason to avoid *you* is in real world they wll be modifying existing code. “hey, it wasn’t **my** variable name! It was like that already and I followed consistently.”
Answers.UserDisplayName: JDługosz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-06T04:17:50.547Z
Answers.Text: Unless you're coding python,  don't bother judging indentation. Modern editors take care of that for you.   Ctrl+a ctrl+shift+f will strictly style code to language preferred spec in most languages in my preferred (free) editor.
Answers.UserDisplayName: pojo-guy
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-06T06:26:46.303Z
Answers.Text: @pojo-guy But it should be the *author* pressing the keys to do the formatting (before submitting!), not the *reviewer.* If the code is badly indented by review time, it certainly merits pointing out.
Answers.UserDisplayName: Angew is no longer proud of SO
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-06T11:45:27.883Z
Answers.Text: Since code reviews are typically done in the editor on a projector,  it's not unusual to do that at the code review if it is needed (or at all). Spacing is just something that doesn't get talked about in a real code reviews in languages where spacing has no semantic meaning. Python and COBOL are different because spaces change the logic of the program.
Answers.UserDisplayName: pojo-guy
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-08T15:41:57.717Z
Answers.Text: @sixtyfootersdude - I want to add a caveat to your comment. For me, as a tall white male, if I say "I am confused by..." then students will take that to mean they should probably revise their code (as you suggested). But if one of my female colleagues said that, students might take it as her actually being confused, and it might feed into their biases against her. In the end, it could cause more student resistance against her. I like Buffy's wording best.
Answers.UserDisplayName: David White
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-05T07:44:46.103Z
Answers.LastActivityDate: 2017-07-05T07:44:46.103Z
Answers.UserDisplayName: Peter
Answers.Body: <p>My year 4 teacher at primary school taught me how to shade rounded objects - by doing so on a picture I had been working on for quite some time.<br>
  I recognise now that it did improve the picture, but I was <em>furious</em> at the time; because I had lost control of my work, and I didn't want or feel the need for the help at that time.  </p>
  
  <p>There are two points that I think this exemplifies:</p>
  
  <ul>
  <li>Don't take control of the work away from the student.  It can prevent them from wanting to improve it, as it isn't 'theirs' any more</li>
  <li>Show them what can be improved, and how to do it, to encourage them to recognise faults and improve their own work.</li>
  </ul>
  
  <p>One thing you could do, if you see common problems, is to generate your own examples of poor quality code, and get them to improve it themselves. In doing so, they will learn to recognise the problems with their own work.</p>
  
  <p>If feasible, find something that requires criticism to be taken on-board to show them the positives that come from improving their code - e.g. if your students are having problems with correct indentation: "This week class, we are going to introduce ourselves to python".</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-05T16:05:28.553Z
Answers.Text: We're always glad to have thoughtful responses from the student perspective. Welcome to [cseducators.se]. I hope we hear more from you in the future!
Answers.UserDisplayName: Ben I.
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-07T21:46:31.190Z
Answers.Text: This is a great response. I wish I had more feedback like this - constructive, from the student's point of view. Teaching is hard - most of us *want* to be better.
Answers.UserDisplayName: 3Dave
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-05T16:02:31.570Z
Answers.LastActivityDate: 2017-07-06T17:00:30.483Z
Answers.LastEditDate: 2017-07-06T17:00:30.483Z
Answers.UserDisplayName: Baldrickk
Answers.Body: <p>I would stress that code reviews occur frequently in industry, both formal and informal. Even senior software developers have code reviews. They are not just for improving code quality. Code reviews also communicate changes and teach other developers. One important lesson I learned early on in my career is that there's <em>always</em> someone who knows more than you. You are hurting yourself if you don't learn from them. Of course it shouldn't be all criticism. I often highlight innovative, elegant, and efficient coding examples. The <a href="https://www.gottman.com/blog/the-positive-perspective-dr-gottmans-magic-ratio/" rel="noreferrer">Magic Ratio</a> apples in classrooms too.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-05T15:00:54.707Z
Answers.LastActivityDate: 2017-07-05T15:00:54.707Z
Answers.UserDisplayName: Edwin Torres
Answers.Body: <p>There are both personal and technical aspects to this question. First, on a personal level:</p>
  
  <p>Do you have an informal, friendly relationship with your students, or a formal one. If your relationship is strictly formal and you are seen as an "authority figure" you need to be much more careful here. I could do things with students that, for example, my very proper European dissertation advisor could never get away with. Even if your students think of you as a bit goofy ("tells eye-rolling jokes", "very punny") you can do dramatic things. Part of the mythology around my teaching persona is that I once held my nose and dropped a student paper into the trash. I don't think it happened, actually, but it was the kind of thing that "might" have happened. If the personal relationship is strong you can move upward from that and your message will be remembered. </p>
  
  <p>However, being constantly dramatic is probably counterproductive, as it loses its force if used too often. </p>
  
  <p>If you are more formal, or a new teacher without a myth (yet), use more structured means, such as, for example, what @Peter♦ suggests here. </p>
  
  <p>On the more technical side you can prepare ahead some reusable materials that you can use to make various points. If a student is using terrible variable names (a former student of mine used NSFW references exclusively) give them a program in which you have obfuscated names (<code>v1</code>, <code>v2</code>, ...) and ask for an analysis. Two pages of code will be enough. If the problem is poor structure, give them one with (much) worse structure and ask for an analysis. In other words, show them, in a dramatic way, the effect of the kind of errors they are making. If you are teaching OO Java, for example, a program with the "one true method" solving all, can be pretty dramatic. Nest those selection statements to the max. </p>
  
  <p>Such programs can have use year after year, so you can amortize the development cost. You can even use old student programs that have been disguised, perhaps. </p>
  
  <p>If the problem is a failure to meet the requirements, giving them a few tests to pass can help, but this may be harder to amortize. </p>
  
  <p>If you have industry experience an/or connections, perhaps you can show them samples of poor coding that had an effect on the organization. If you still have colleagues there (or former students) perhaps they can help with samples. </p>
  
  <p>Echoing @Peter♦, make it about the work, not about the student. </p>
  
  <hr>
  
  <p>In a slightly different direction, I think that you can't "tell" a student to "not be discouraged." It isn't something you can teach with words, especially in the moment of need. You can talk about it in general before the need arises, of course. However, when the student needs specific guidance, it isn't likely to be useful to say "this is terrible, but don't be discouraged". You have to get them to <em>Embrace Correction</em>. And if you Embrace Correction yourself, accepting feedback from students and acting on it, it can help. At the moment of need, advise so that emotion and personal feelings don't come in to the picture. You want the student to carry away "my program can be improved", not "I need improvement." &lt; opinion ></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-05T12:38:07.623Z
Answers.Text: I'm definitely the goofy, informal sort of professor, although I have a background that gives me credibility.
Answers.UserDisplayName: Ellen Spertus
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-05T12:39:33.303Z
Answers.Text: yes, of course. Goofy and Credible aren't inconsistent. But you need to build your myth carefully and slowly if you are new to the game. I took Mike Clancy as a role-model
Answers.UserDisplayName: Buffy
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-06T00:36:23.220Z
Answers.Text: What is “one true method”?
Answers.UserDisplayName: JDługosz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-06T00:39:31.090Z
Answers.Text: Reading code with poor structure doesn't seem to teach real-world coders to do better, or to even see the problem in my experience.  Why would it help for students?  It just teaches them that it’s normal for code to need decyphering to figure out, before working on it.
Answers.UserDisplayName: JDługosz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-06T09:22:14.793Z
Answers.Text: @JDługosz Sorry, I was a bit cryptic. I was referring to a complex task that implements it in one class with one method. Actually, I've had some success with discussing such poor structure code, but also showing a better way.
Answers.UserDisplayName: Buffy
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-05T11:42:39.587Z
Answers.LastActivityDate: 2017-07-06T16:25:08.530Z
Answers.LastEditDate: 2017-07-06T16:25:08.530Z
Answers.UserDisplayName: Buffy
Answers.Body: <p>Being a relatively young tutor (and soon to be informal teacher), I have quite a few examples of bad code that I wrote not too long ago. </p>
  
  <p>If you have no such code then you can simply write some (purposefully buggy and bad), then show it to your students. </p>
  
  <p>The point of this is to explain that had you not taken criticism of that code constructively, your own learning would be impaired. Because one never actually stops learning, I'm sure you can find recent examples of this and use them. Why, even this site <em>might</em> be an example. If you received criticism on an answer or question, then to actually "learn from your mistakes" you'd have to take criticism constructively.</p>
  
  <p>Also, it's important to make them see that without criticism, they have no feedback, and with no feedback whatsoever, it is literally impossible to learn (I'll also add that if they know a bit of machine learning or neural networks then you can use that example: without feedback, neural networks learn so slowly).</p>
  
  <p>It's also important that you give your criticism in a constructive way (I'm sure you do but one should keep it in mind) and then explain to the students that criticism should be taken constructively, because it means there's room for improvement, and the criticism is the key to opening the door to that room.</p>
  
  <p>I saw many students (that studied with me or that I tutored) who were encouraged to take criticism constructively because they were shown by the teacher (who was sometimes myself) just how important it is.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-05T05:01:17.517Z
Answers.LastActivityDate: 2017-07-05T05:01:17.517Z
Answers.UserDisplayName: ItamarG3
Answers.Body: <p><strong>Tl/Dr</strong>: Interact with each student individually.  Also, I wrote this answer mostly because I wanted to have fun with the list of students at the end.  It probably shows, but hopefully it's useful!</p>
  
  <p>So I haven't seen your interaction style with your students.  I don't know where the challenges exist.  However, one thing I have found to be <em>generally</em> true is that the phrase "take criticism constructively" is a tricky one.  It's so easy to put all the onus on the receiver of the criticism, insisting that they take it "constructively."</p>
  
  <p>I think some of what makes it hard is that the phrase doesn't include the provider of the criticism.  It, instead, focuses on the "criticism," like it's already out in the open.  Now the ability to take criticism like this and turn it into something constructive <em>is</em> an important life skill, but the thing about life skills is that they take a lifetime to develop.  You might have a few hours with the students for a year, if that.  You can show them the path towards how to take criticism constructively, but you can't expect them to walk all that far down it in a year.</p>
  
  <p>The key, like anything else in teaching or the rest of life, is individual attention to the students.  You have to look at what's going on in their minds.  And, of course, I strive to say this with the utmost humility: for me, this is a life skill that's going to take a lifetime... and sometimes it feels like it'll take two or three.  But that's okay.  I still feel like I can say the phrase and have the phrase be true, even when I strugle with doing it.</p>
  
  <p>What I have found very effective is to take the word "constructively" literally and see how far I can run with it.  Consider the "stationary" points in the mind of a young student -- the things which are moving slow enough to be worth directing.  Some of them are already constructed.  They're stationary things like facts and beliefs which are already there.  You can't constructively criticize those, because they're already constructed.  They're done.  All you can do to change them is be destructive.  All you can do is tear them down and then try to show them what they should build up in its place.  Doing so is certainly part of teaching, but it's not "constructive criticism."</p>
  
  <p>The other stationary point is more interesting, and far harder to see.  These are the energetic holes in their lives where something could be constructed.  These happen during growing up, and they also happen when an individual decides one of their beliefs shouldn't be so solid and tears it up.  They then hold onto that potential looking for something to build in its place.  This is where constructive criticism is tremendously powerful.  If you can resolve something in their mind just by suggesting somewhere to put their load, the students will rapidly accept your offer.</p>
  
  <p>Note that this version of constructive criticism requires something in their mind already -- a desire to construct.  You have to look for where they want to construct things, and make it happen.  Consider the following students:</p>
  
  <ul>
  <li><strong>Alice</strong> has already decided she's going to be a programmer when she grows up.  Accordingly, she's already got a thirst to learn from you simply because you're the CS teacher.  A student such as this may give you great opportunities for constructive criticism.  You may be able to provide her "breadcrumbs" guiding her and refining her skills, each time just barely within her reach.  You might suggest she look at design patterns, when the rest of the class is struggling over <code>private</code> vs <code>public</code>.  Also, because she's already interested, she's going to be inspecting anything along her career path carefully.  If you help her put something down, and it lands in the wrong place, she will unearth it and try again.  Give her suggestions about how to shoot for the stars, and she'll construct a bridge to get there.</li>
  <li><strong>Bob</strong> is in the process of going through lots of life changes.  Everything is in flux for him.  Maybe his voice cracks, maybe his code doesn't compile on the latest release of RHEL.  Bob might be interested in finding some stability from the course.  Perhaps you can show him how programming can help him think in ways which anchors pieces of his life.  Perhaps you can show him how programming is a stable life that he might enjoy.  Give him suggestions about how to build rock-solid code which won't break.</li>
  <li><strong>Charlie</strong> is the outsider in this communication.  He's just the football jock who got stuck in a CS course.  Maybe he doesn't really need programming at all.  However, he does need leadership skills.  See if there's a way to structure a group project such that having a strong leader is useful, even if they're not all that strong at writing software.  Perhaps there's some customer interactions that need to take place?  I mean, we all know the customer is a mythical beast whose feet never touch the ground, right?  As it turns out, in customer relationships, there's rarely a "right" answer nailed down in stone.  Everything has some potential to change, which makes constructive criticism easier.</li>
  <li><strong>Eve</strong>.  There's always an Eve.  Slightly malicious, always trying to find ways to cheat.  Eves are tough.  That's why she's always trying to eavesdrop on our public key encryption.  But everyone is <a href="https://xkcd.com/177/" rel="nofollow noreferrer">human</a>.  I'd say find your own way for dealing with each Eve, but if you can remember that they're human, it's certainly possible to make it work.</li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-05T18:53:22.843Z
Answers.LastActivityDate: 2017-07-05T18:53:22.843Z
Answers.UserDisplayName: Cort Ammon
Answers.Body: <p>There have been many great answers so far, so I'll be brief. The students of mine who have difficulty with accepting criticism are often in a "fixed mindset" rather than a "growth mindset", with terminology from <a href="http://rads.stackoverflow.com/amzn/click/0345472322" rel="nofollow noreferrer">Carol Dweck</a>. Most of my students have been high achievers all their lives. Some have got their self-worth bound up with being "good at" computer science (this is a "fixed" mindset). For those, criticism is interpreted as an attack on their self-worth. The other answers are trying to give ways to phrase criticism so it won't be interpreted in this way. I propose, trying to change the students (switching them to "growth" mindsets), so that they realize that they can always get better, and view constructive criticism as a way to do so. This is obviously a lot more work, but I think it's possibly the most valuable thing we can really teach our students.</p>
  
  <p>Our college president is a big fan of this work of Dweck, so he made a campus-wide push to help students make this switch. They learn about Dweck's work during orientation, and then students are put into "advising circles" that meet once or twice a week for their first semester on campus. The circle has a faculty advisor, and 12 students. It's 1 credit (1/4 of a full course). The advisor can give students things to read, or journaling assignments. So far, it seems to be helping. Our retention rate is up, and there are fewer confrontational students. Generally speaking, if I have a problem student, I think one of the best ways to change his behavior is to put him in a situation where his peers point that he is the only one with a problem. The advising circles help with that.</p>
  
  <p>Incidentally, I think the president initiated this move with the writing program in mind. Many students are resistant to criticism about their writing skills, and humanities professors have been dealing with this forever. I'll bet there is a lot we can learn from them, and I wonder if they also have journals for humanities-educators, where we could read what they've come up with.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-09T10:58:18.020Z
Answers.Text: It is probably worth trying to factor out "growth mindset" into a separate thread. Can you pose a question? "How can we transform students..." I don't know enough to take the lead on this.
Answers.UserDisplayName: Buffy
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-09T13:18:59.297Z
Answers.Text: Thanks for the suggestion. Let me think about it a bit and see if I come up with a good question.
Answers.UserDisplayName: David White
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-09T14:13:27.850Z
Answers.Text: You might want to visit [the classroom](https://chat.stackexchange.com/rooms/59174/the-classroom) to help formulate it.
Answers.UserDisplayName: Buffy
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-09T14:21:43.270Z
Answers.Text: I think the answer should be left here. It's a great one.
Answers.UserDisplayName: Ellen Spertus
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-09T05:34:20.413Z
Answers.LastActivityDate: 2017-07-09T05:34:20.413Z
Answers.UserDisplayName: David White
Answers.Body: <p>I think this question boils down into two generic parts:</p>
  
  <ol>
  <li>How to criticise in a way that doesn't trigger defensive behaviour, and;</li>
  <li>How to teach them how to handle criticism</li>
  </ol>
  
  <p>I think the first port of call would be to bring up the subject of handling criticism <em>as a dedicated class session</em>, including <em>how to extract useful feedback from poor criticism</em>, and <em>how to make criticism</em> (which they would be expected to do in the event of a code review, both reviewer and reviewee). They're adults, bring them on the level of both giving and receiving, and they should understand both sides.</p>
  
  <p>On the other side of the fence, how to criticise I find boils down into two categories:</p>
  
  <ol>
  <li>Subjective (EG this could look nicer)</li>
  <li>Objective (EG if you don't implement this, it will crash, and bad things will happen)</li>
  </ol>
  
  <p><strong>Subjective</strong></p>
  
  <p>On subjective criticisms, I find making 'speculative' recommendations passively works best, especially with reasoning listed. So say Joey forces all his code onto a single line, you'd say:</p>
  
  <blockquote>
    <p>Joey, I've noticed that in this code, everything is on a single line! I think maybe - just a suggestion - having it on multiple lines might make it easier for other people to read.</p>
  </blockquote>
  
  <p>Joey has a couple of choices here. He can consider you've got a fair point, and might go for it, or, better yet, Joey will present the list of arguments as to why he has it on a single line (maybe 'no-one else will see my code' or 'I'm doing a contest on fewest bytes used on code gold'). At which point you can either explain why not building it for other people in mind is bad, or concede there is a reasoning behind it.</p>
  
  <p>This approach I find is excellent in team situations because the suggestions aren't forced, and it allows people to argue for/against a particular criticism. A dialogue occurs, instead of an argument.</p>
  
  <p><strong>Objective</strong></p>
  
  <p>This is where real problems begin. It's not because Joey has made an error, but if he continues with the error, stuff will catch on fire, the world is going to end and goto loops will become fashionable again. As a result, you're required to put your foot down.</p>
  
  <p>Before approaching, I find it works extremely well if the opening dialogue starts 'this is nothing personal, <em>but</em>...'. Psychologically, people think it's reverse psychology and thus terrible, but when you point to the code, this helps reinforce it's actually not.</p>
  
  <p>The criticism should be kept short, matter-of-fact 'if this happens it will do this' (if this has no try-catch and it throws an exception, the stack is going to crash and the system will go boom). Explain what-why and how to fix it.</p>
  
  <p>You can help reduce the sense of it being a personal failure (the main driver of being defensive) by either indicating it's a common problem or that it's a hard problem to spot. Joey might still get defensive, however: trick is to not rise to the argument.</p>
  
  <p>So, for example:</p>
  
  <blockquote>
    <p>This is nothing personal, but, in line 232 of main.cpp, I've noticed that a try-catch statement is missing, which means exceptions are not being handled. If an exception isn't handled here, function ProcessArray might throw a memory allocation error which will cause the program to crash.</p>
  </blockquote>
  
  <p>Joey might defensively respond:</p>
  
  <blockquote>
    <p>But on modern machines a memory allocation error is bound to never occur, so there's no need for a try-catch statement. Besides, I'm doing it for readability!</p>
  </blockquote>
  
  <p>At which point you sidestep the approaching argument, and simply return to matter-of-fact and a clean exit:</p>
  
  <blockquote>
    <p>Good programming standards dictate that programs gracefully exit in the event of a major error, as crashing might impact the systems, if any, that rely upon it, especially to not crash. Operating Systems are a prime example of this. You might find a different workaround for this problem.</p>
  </blockquote>
  
  <p>I find some people hate being told what to do, and will spurn it even if it's the most logical choice. By alerting Joey to the problem, the solution, the reasons for that solution and the fact there might be other solutions, allows Joey to see the problem as an impersonal thing for him to solve (he didn't create the mem alloc error: he has to solve it), he has one known solution, and the freedom to research other unknown solutions.</p>
  
  <p>Joey can either see your solution as the easiest, might devise his own solution (which might be surprising - as a student, he should be learning, not merely copying), or might just choose to ignore it, in which case he suffers the consequences (bonus points if you can create a scenario that causes the error), including any subsequent markdowns on program's performance.</p>
  
  <p><strong>Final trick</strong></p>
  
  <p>If you want to be really hands off, there is one question that will get most people to reconsider a piece or line of code that doesn't require explanation:</p>
  
  <p><strong>What happens if</strong> ... </p>
  
  <p>What happens if this ProcessArray hits a mem alloc error?</p>
  
  <p>What happens if this switch statement encounters an unknown case?</p>
  
  <p>etc</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-07T16:47:35.083Z
Answers.LastActivityDate: 2017-07-07T16:47:35.083Z
Answers.UserDisplayName: SE Does Not Like Dissent
Body: <p>How do you encourage students to benefit from code reviews you give them, rather than being discouraged or responding defensively?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-05T11:05:06.887Z
Comments.Text: Find something that requires that criticism to be taken on-board to show them the positives that come from improving their code - e.g. if your students are having problems with correct indentation: _"This week class, we are going to introduce ourselves to python"._
Comments.UserDisplayName: Baldrickk
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-05T13:44:23.547Z
Comments.Text: I think that Baldrickk has right, if students aren't really into it aniway they won't really listen feedbacks, but if the feedback become a class, they don't have the choice. And it avoid any form of criticism
Comments.UserDisplayName: Walfrat
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-05T14:49:22.917Z
Comments.Text: I always try to explain to my interns what they are doing wrong, with a calm, patient and encouraging tone. Like _"You see? Here you are reversing the array twice... :)"_ or _"It's not a huge deal, but here you are not validating this input, so you risk throwing an undocumented exception..._" but they always took it personal. Stumped, for weeks, I tried many tones and formulations. In the end, what did the trick for me was to stop finishing each sentence with _"...like an idiot."_
Comments.UserDisplayName: xDaizu
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-05T15:37:01.247Z
Comments.Text: Can you give an example of an interaction that results in a defensive or discouraged response from a student? I would love to add something helpful, but I am having trouble working in the abstract.
Comments.UserDisplayName: Ben I.
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-05T22:05:49.660Z
Comments.Text: I think the general advice for code reviews in the industry is applicable here. Criticize the code, not the coder. "A function call would be cleaner here" instead of "You should have used a function"... I'm guessing most of these people are on the way to becoming junior software engineers, so using industry advice here would be really useful.
Comments.UserDisplayName: L0j1k
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-06T04:13:48.183Z
Comments.Text: Don't waste time judging indentation. Unless you're teaching python,  the editor will do the formatting for you. At one place I worked we had a tool called SONAR, which did automated code reviews,  it was derisively referred to as "some other nerds aesthetic requirements" . However,  using tools like find bugs (java) to guide you towards common bugs is a useful exercise.
Comments.UserDisplayName: pojo-guy
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-06T12:09:36.930Z
Comments.Text: I think you can use your own code as example. You can get an old code and new code and compare the improvement with the class.
  
  This shows that you code will be better with knowledge and how it's importante to be critical with your own code.
Comments.UserDisplayName: Rodrigo Menezes
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-06T21:21:06.140Z
Comments.Text: I like to tell people who are not listening when I do code reviews: Michael Jordan had a coach.
Comments.UserDisplayName: Be Kind To New Users
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-07T14:13:48.643Z
Comments.Text: Don't expect this to be easy; lots of professionals have trouble with this. A few have trouble *giving* code criticism constructively.
Comments.UserDisplayName: T.E.D.
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-07T18:09:53.853Z
Comments.Text: You _must_ be able to actually demonstrate that the code review is worth the effort to them.
Comments.UserDisplayName: Thorbjørn Ravn Andersen
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-07T21:43:34.087Z
Comments.Text: Pointing out that if their test data had 2M datum rather than 1k, their solution would take 100 years to finish, sometimes helps. On the next assignment, give them a test set with 2M datum.
Comments.UserDisplayName: 3Dave
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-07T21:50:35.567Z
Comments.Text: Also, I offered 5 bonus points on the next test to any student that found a bug in my code, or a way to make it more efficient. You might be surprised how eager some students are to find issues with the professor's code. I happily gave out lots of bonus points.
Comments.UserDisplayName: 3Dave
Tags: <student-motivation>
Title: How do you encourage students to take criticism of their code constructively?
ThreadText: # How do you encourage students to take criticism of their code constructively?
  
  (Asked by: username_0 on 2017-07-05)
  
  How do you encourage students to benefit from code reviews you give them, rather than being discouraged or responding defensively?
  
  **Tags:** student-motivation
  
  > **Comments:**
  > **username_1**: Find something that requires that criticism to be taken on-board to show them the positives that come from improving their code - e.g. if your students are having problems with correct indentation: _"This week class, we are going to introduce ourselves to python"._  
  > **username_2**: I think that username_1 has right, if students aren't really into it aniway they won't really listen feedbacks, but if the feedback become a class, they don't have the choice. And it avoid any form of criticism  
  > **username_3**: I always try to explain to my interns what they are doing wrong, with a calm, patient and encouraging tone. Like _"You see? Here you are reversing the array twice... :)"_ or _"It's not a huge deal, but here you are not validating this input, so you risk throwing an undocumented exception..._" but they always took it personal. Stumped, for weeks, I tried many tones and formulations. In the end, what did the trick for me was to stop finishing each sentence with _"...like an idiot."_  
  > **username_4**: Can you give an example of an interaction that results in a defensive or discouraged response from a student? I would love to add something helpful, but I am having trouble working in the abstract.  
  > **username_5**: I think the general advice for code reviews in the industry is applicable here. Criticize the code, not the coder. "A function call would be cleaner here" instead of "You should have used a function"... I'm guessing most of these people are on the way to becoming junior software engineers, so using industry advice here would be really useful.  
  > **username_6**: Don't waste time judging indentation. Unless you're teaching python,  the editor will do the formatting for you. At one place I worked we had a tool called SONAR, which did automated code reviews,  it was derisively referred to as "some other nerds aesthetic requirements" . However,  using tools like find bugs (java) to guide you towards common bugs is a useful exercise.  
  > **username_7**: I think you can use your own code as example. You can get an old code and new code and compare the improvement with the class.  This shows that you code will be better with knowledge and how it's importante to be critical with your own code.  
  > **username_8**: I like to tell people who are not listening when I do code reviews: username_20 Jordan had a coach.  
  > **username_9**: Don't expect this to be easy; lots of professionals have trouble with this. A few have trouble *giving* code criticism constructively.  
  > **username_10**: You _must_ be able to actually demonstrate that the code review is worth the effort to them.  
  > **username_11**: Pointing out that if their test data had 2M datum rather than 1k, their solution would take 100 years to finish, sometimes helps. On the next assignment, give them a test set with 2M datum.  
  > **username_11**: Also, I offered 5 bonus points on the next test to any student that found a bug in my code, or a way to make it more efficient. You might be surprised how eager some students are to find issues with the professor's code. I happily gave out lots of bonus points.  
  
  ---
  
  ## 14 answers
  
  ### Answer by username_18 on 2017-07-05. Score: 25
  
  Here a few techniques I use in my class when giving feedback on student code:
  
  * **Use a rubric.** CS50 has a clear grading approach: code is assessed along the four axes of scope, correctness, design, and style. Within style for example, I might focus particularly on readability vis-à-vis indentation. If a student is marked down on this item, she knows exactly what she missed and why she may have lost points. The clearer the criteria of evaluation, the better the student response to being assessed on said criteria. I also think it's valuable to share rubrics in advance. Only seeing it after the fact can make students feel like how they were being graded was being kept a secret, which can lead to resentment of feedback.
  * **Avoid "you" statements.** This is something I caught myself doing and tried to correct as the year went on. Let's say I'm reviewing a student's code, and I'm commenting on the naming of variables. I might be tempted to say, "*You* have unclear variable names here." That frames it as an assessment of the student, not of the code, which does not set the right dynamic. I try to make sure I say something like this now: "*Your program* has unclear variable names here" or "to improve *your code*, make *your program's* variable names more precise." The goal is give feedback on the code, not the coder, so language should reflect that focus. (Side note: with how personally code reviews can be taken, I think how we frame the language of assessment is essential to building proper classroom culture when it comes to grades and feedback.)
  * **Reward revision.** This one is possibly more applicable at the high school level, but I think it does matter in terms of building a culture of receptiveness to code review feedback. Allowing students to revise their work gave me the ability to see students improve their work based on my commentary. In my mind this is what education is all about: inspiring a continual learning process. The pragmatics will vary from context to context, but requiring some sort of revision or reflection or allowing students to "recover" some/all lost points communicates to them that at the end of the day, you want them to be better programmers. Grades take a backseat to learning. Again, this might make less sense for university students, but in my class this approach goes a long way in terms of students constantly working on improving their craft.
  
  > **Comments:**
  > **username_19**: I agree, but you can go further. Instead of "Your program has unclear variable names here", try "_The program_ has unclear variable names here". Make it all about the program. Reward Revision is brilliant and should be a pedagogical pattern. But I'd dispute your "restriction" to secondary level. You can do it with doctoral students (imo) in their preparatory work. And "reward" can be more general than points.  
  > **username_19**: The Embrace Correction Pedagogical Pattern is very similar to Reward Revision: "Give the student the chance to improve their artifacts."  
  > **username_20**: I was also thinking that "our program" and what "we" might want to do might work  
  > **username_21**: @username_19 I'm amused that in the comment here, instead of saying "I agree, but this answer can go further" it says "I agree, but __you__ can go further." It shows how difficult it actually is to provide this sort of criticism!  
  > **username_19**: @username_21 I'm amused by _your_ comment here. I think < opinion > that when you give positive advice and encouragement _you_ can use _you_ just fine. But I take your meaning, and thanks.  
  > **username_22**: I might go one step further than **Avoid "you" statements**.  I think would I could recommend is to **use "I" statements**.  Say things like, "I am confused by this variable name".  This shows that the feedback is somewhat subjective.  
  > **username_23**: Another reason to avoid *you* is in real world they wll be modifying existing code. “hey, it wasn’t **my** variable name! It was like that already and I followed consistently.”  
  > **username_6**: Unless you're coding python,  don't bother judging indentation. Modern editors take care of that for you.   Ctrl+a ctrl+shift+f will strictly style code to language preferred spec in most languages in my preferred (free) editor.  
  > **username_24**: @username_6 But it should be the *author* pressing the keys to do the formatting (before submitting!), not the *reviewer.* If the code is badly indented by review time, it certainly merits pointing out.  
  > **username_6**: Since code reviews are typically done in the editor on a projector,  it's not unusual to do that at the code review if it is needed (or at all). Spacing is just something that doesn't get talked about in a real code reviews in languages where spacing has no semantic meaning. Python and COBOL are different because spaces change the logic of the program.  
  > **username_25**: @username_22 - I want to add a caveat to your comment. For me, as a tall username_25 male, if I say "I am confused by..." then students will take that to mean they should probably revise their code (as you suggested). But if one of my female colleagues said that, students might take it as her actually being confused, and it might feed into their biases against her. In the end, it could cause more student resistance against her. I like username_19's wording best.  
  
  ---
  
  ### Answer by username_1 on 2017-07-05. Score: 20
  
  My year 4 teacher at primary school taught me how to shade rounded objects - by doing so on a picture I had been working on for quite some time.  
  I recognise now that it did improve the picture, but I was *furious* at the time; because I had lost control of my work, and I didn't want or feel the need for the help at that time.
  
  There are two points that I think this exemplifies:
  
  * Don't take control of the work away from the student. It can prevent them from wanting to improve it, as it isn't 'theirs' any more
  * Show them what can be improved, and how to do it, to encourage them to recognise faults and improve their own work.
  
  One thing you could do, if you see common problems, is to generate your own examples of poor quality code, and get them to improve it themselves. In doing so, they will learn to recognise the problems with their own work.
  
  If feasible, find something that requires criticism to be taken on-board to show them the positives that come from improving their code - e.g. if your students are having problems with correct indentation: "This week class, we are going to introduce ourselves to python".
  
  > **Comments:**
  > **username_4**: We're always glad to have thoughtful responses from the student perspective. Welcome to [cseducators.se]. I hope we hear more from you in the future!  
  > **username_11**: This is a great response. I wish I had more feedback like this - constructive, from the student's point of view. Teaching is hard - most of us *want* to be better.  
  
  ---
  
  ### Answer by username_16 on 2017-07-05. Score: 11
  
  I have always enjoyed the fact that as a programming teacher I have almost no need to invest time into building up authority (at least not when teaching young adults). Unlike many other fields we always have a computer at hand that will tell us about the mistakes we make, and as soon as we are talking about more complex topics like code design there is always an explanation why something is considered good or bad style.
  
  The result is that I don't see any need to express negativity in my code reviews. I know that good programmers will think of sub-optimal code as horrible mistakes, that's what drives us to improve our code constantly and not be fine with anything that works.
  But for students getting something to run and do what they want it to is often a huge achievement, not just subjectively but also objectively. If the code doesn't do what they want they will be open for suggestions anyway, so this question will most likely be about situations where the student may argue that "it's working, so why bother listen to your advice?".
  
  The solution I found for myself is to avoid arbitrary rules. Don't tell students what they "have to do" unless they actually have to do it in order to get something to run. Otherwise they will immediately see that what you are telling them is factually wrong, since they didn't do it your way and it still runs, so apparently they didn't "have to do" it.
  
  Instead try to illustrate the upsides and downsides of their solution and your alternative solution. In most cases it's easy to come up with a simple test that allows you to demonstrate the benefits of your suggestions. For example if it's about code design have the student rewrite a short paragraph according to your suggestions and then ask someone who doesn't know the code and wasn't involved in the conversation to summarize what the code does. Usually the improvement will be quite obvious.
  If your advice was good and you communicated it the right way the student will be proud that they were able to improve their code, since the whole demonstration revolved around the code the student rewrote and the reaction they got. You and your authority (i.e. the things that might trigger pride and make the student eager to prove you wrong) are out of the equation.
  
  If it's not about code design but about things like architecture illustrate it with a reasonable change request that would be more difficult to implement with the "bad" architecture you want to argue against.
  
  Of course tests like these will fail sometimes and the "improved" code will not work better, but if that's the case and you don't see a flaw in the way your suggestions were implemented, then this may actually teach you that your advice isn't as powerful as you thought it was, and reflecting that to the students in a mature way will even improve the respect the students have, because you are demonstrating that it's not you against them, it's all of you against the hard facts.
  
  
  ---
  
  ### Answer by username_4 on 2017-07-05. Score: 10
  
  Feedback can be intrinsically threatening, and people are open to feedback only under the right conditions. Here is an [excellent article](https://open.buffer.com/how-to-give-receive-feedback-work/) that discusses the psychology of feedback. In their summary, feedback can be received when:
  
  * The feedback provider is credible in the eyes of the feedback recipient.
  * The feedback provider is trusted by the feedback recipient.
  * The feedback is conveyed with good intentions.
  * The timing and the circumstances of giving the feedback are appropriate.
  * The feedback is given in an interactive manner.
  * The feedback message is clear.
  * The feedback is helpful to the recipient.
  
  As for the classroom context, I believe that the two most important things have already been said by username_18 and username_19: keep the focus on the code, not on the student, and make sure that you have a warm relationship with your students.
  
  What little piece I would add would be that, *given the above*, if the things you are asking your students to do have self-apparent value, then the resistance never appears in the first place. If they don't have self-apparent value, then asking the question "how can I make sure my students are receptive to what I have to say" is the wrong question, something more fundamental is missing in the presentation.
  
  My biggest victory in this regard was when I figured out how to teach about coding style. I could not *for the life of me* figure out how to present it as something with intrinsic value. The code that we worked on was all short enough that it hardly mattered, the kids were perfectly able to understand their *own* code, and my protestations aside, the kids couldn't see any good reason to put thought and effort into indentation, variable names, function names, clean organization, etc.
  
  I outlined how I eventually solved that problem [here](https://cseducators.stackexchange.com/a/132/27). By the time I finally had it sorted out, the kids started to see *intrinsic value* to clarity in their code, so the suggestions I gave to help them achieve that end were no longer met with resistance.
  
  > **Comments:**
  > **username_17**: your examples at the link here https://cseducators.stackexchange.com/questions/130/how-to-teach-why-indentation-is-important/132#132 are informative!  
  
  ---
  
  ### Answer by username_0 on 2017-07-06. Score: 10
  
  I have all of my students read [Keeping Perspective](https://docs.google.com/document/d/18e0zklTPKzMS9LkzUTIUGEYoMdt86U-Xjwcum5TABQw/edit#heading=h.ohrh5dps3opt), a section of [So you want a code review...](https://docs.google.com/document/d/18e0zklTPKzMS9LkzUTIUGEYoMdt86U-Xjwcum5TABQw/edit?usp=sharing), which I wrote when working on an open source project. It's short enough that I'll excerpt it here:
  
  > **Keeping Perspective**
  >
  > [![October 12, 2001 Hackles cartoon](https://i.sstatic.net/nOhwy.png)](https://i.sstatic.net/nOhwy.png)
  >
  > I began working at Google when on sabbatical after having been granted
  > tenure early at Mills College, where I had been working since becoming
  > MIT$^3$ (SB, SM, and PhD). As a professor, I had been the sole judge of
  > others’ code. I expected to sail through my first code review and
  > hear that they had never seen such excellent code before.
  >
  > That’s not what happened. To give you an idea of what did, here is
  > the art that was created from my suffering, since reshared by many
  > other Googlers:
  >
  > > **The [Five Stages](http://en.wikipedia.org/wiki/K%C3%BCbler-Ross_model) of Dealing with a Code Review**
  > >
  > > 1. Disbelief: "How could someone find so much to complain about in my code?!"
  > > 2. Anger: "How dare someone suggest that a hash-map of hash-maps isn't an efficient way of storing data?"
  > > 3. Bargaining: "Maybe if I add the comments the reviewer requested in one file, I won't have to fix the tricky Unicode issues in another."
  > > 4. Depression: "There was so much wrong with my code. How can I show my face to the person who reviewed my code?"
  > > 5. Acceptance: "Wow, my code is a lot better due to the feedback. This is a useful process, although I bet it's occasionally painful for everyone."
  > >
  > > It’s much better not [to take suggestions personally](http://abstrusegoose.com/381).
  
  I also try to model an openness to feedback by soliciting suggestions on how to improve my teaching and putting them into practice immediately. (To see how well I succeed at this goal, I add this question to the end-of-semester evaluations: "The instructor responds well to and incorporates student feedback.")
  
  I begin code reviews by congratulating students on what they've accomplished and telling them I'll show them how to make their code even better (as suggested by kayleeFrye\_onDeck).
  
  
  ---
  
  ### Answer by username_26 on 2017-07-05. Score: 6
  
  I would stress that code reviews occur frequently in industry, both formal and informal. Even senior software developers have code reviews. They are not just for improving code quality. Code reviews also communicate changes and teach other developers. One important lesson I learned early on in my career is that there's *always* someone who knows more than you. You are hurting yourself if you don't learn from them. Of course it shouldn't be all criticism. I often highlight innovative, elegant, and efficient coding examples. The [Magic Ratio](https://www.gottman.com/blog/the-positive-perspective-dr-gottmans-magic-ratio/) apples in classrooms too.
  
  
  ---
  
  ### Answer by username_19 on 2017-07-05. Score: 6
  
  There are both personal and technical aspects to this question. First, on a personal level:
  
  Do you have an informal, friendly relationship with your students, or a formal one. If your relationship is strictly formal and you are seen as an "authority figure" you need to be much more careful here. I could do things with students that, for example, my very proper European dissertation advisor could never get away with. Even if your students think of you as a bit goofy ("tells eye-rolling jokes", "very punny") you can do dramatic things. Part of the mythology around my teaching persona is that I once held my nose and dropped a student paper into the trash. I don't think it happened, actually, but it was the kind of thing that "might" have happened. If the personal relationship is strong you can move upward from that and your message will be remembered.
  
  However, being constantly dramatic is probably counterproductive, as it loses its force if used too often.
  
  If you are more formal, or a new teacher without a myth (yet), use more structured means, such as, for example, what @username_18♦ suggests here.
  
  On the more technical side you can prepare ahead some reusable materials that you can use to make various points. If a student is using terrible variable names (a former student of mine used NSFW references exclusively) give them a program in which you have obfuscated names (`v1`, `v2`, ...) and ask for an analysis. Two pages of code will be enough. If the problem is poor structure, give them one with (much) worse structure and ask for an analysis. In other words, show them, in a dramatic way, the effect of the kind of errors they are making. If you are teaching OO Java, for example, a program with the "one true method" solving all, can be pretty dramatic. Nest those selection statements to the max.
  
  Such programs can have use year after year, so you can amortize the development cost. You can even use old student programs that have been disguised, perhaps.
  
  If the problem is a failure to meet the requirements, giving them a few tests to pass can help, but this may be harder to amortize.
  
  If you have industry experience an/or connections, perhaps you can show them samples of poor coding that had an effect on the organization. If you still have colleagues there (or former students) perhaps they can help with samples.
  
  Echoing @username_18♦, make it about the work, not about the student.
  
  ---
  
  In a slightly different direction, I think that you can't "tell" a student to "not be discouraged." It isn't something you can teach with words, especially in the moment of need. You can talk about it in general before the need arises, of course. However, when the student needs specific guidance, it isn't likely to be useful to say "this is terrible, but don't be discouraged". You have to get them to *Embrace Correction*. And if you Embrace Correction yourself, accepting feedback from students and acting on it, it can help. At the moment of need, advise so that emotion and personal feelings don't come in to the picture. You want the student to carry away "my program can be improved", not "I need improvement." < opinion >
  
  > **Comments:**
  > **username_0**: I'm definitely the goofy, informal sort of professor, although I have a background that gives me credibility.  
  > **username_19**: yes, of course. Goofy and Credible aren't inconsistent. But you need to build your myth carefully and slowly if you are new to the game. I took Mike Clancy as a role-model  
  > **username_23**: What is “one true method”?  
  > **username_23**: Reading code with poor structure doesn't seem to teach real-world coders to do better, or to even see the problem in my experience.  Why would it help for students?  It just teaches them that it’s normal for code to need decyphering to figure out, before working on it.  
  > **username_19**: @username_23 Sorry, I was a bit cryptic. I was referring to a complex task that implements it in one class with one method. Actually, I've had some success with discussing such poor structure code, but also showing a better way.  
  
  ---
  
  ### Answer by username_27 on 2017-07-05. Score: 5
  
  Being a relatively young tutor (and soon to be informal teacher), I have quite a few examples of bad code that I wrote not too long ago.
  
  If you have no such code then you can simply write some (purposefully buggy and bad), then show it to your students.
  
  The point of this is to explain that had you not taken criticism of that code constructively, your own learning would be impaired. Because one never actually stops learning, I'm sure you can find recent examples of this and use them. Why, even this site *might* be an example. If you received criticism on an answer or question, then to actually "learn from your mistakes" you'd have to take criticism constructively.
  
  Also, it's important to make them see that without criticism, they have no feedback, and with no feedback whatsoever, it is literally impossible to learn (I'll also add that if they know a bit of machine learning or neural networks then you can use that example: without feedback, neural networks learn so slowly).
  
  It's also important that you give your criticism in a constructive way (I'm sure you do but one should keep it in mind) and then explain to the students that criticism should be taken constructively, because it means there's room for improvement, and the criticism is the key to opening the door to that room.
  
  I saw many students (that studied with me or that I tutored) who were encouraged to take criticism constructively because they were shown by the teacher (who was sometimes myself) just how important it is.
  
  
  ---
  
  ### Answer by username_28 on 2017-07-05. Score: 3
  
  **Tl/Dr**: Interact with each student individually. Also, I wrote this answer mostly because I wanted to have fun with the list of students at the end. It probably shows, but hopefully it's useful!
  
  So I haven't seen your interaction style with your students. I don't know where the challenges exist. However, one thing I have found to be *generally* true is that the phrase "take criticism constructively" is a tricky one. It's so easy to put all the onus on the receiver of the criticism, insisting that they take it "constructively."
  
  I think some of what makes it hard is that the phrase doesn't include the provider of the criticism. It, instead, focuses on the "criticism," like it's already out in the open. Now the ability to take criticism like this and turn it into something constructive *is* an important life skill, but the thing about life skills is that they take a lifetime to develop. You might have a few hours with the students for a year, if that. You can show them the path towards how to take criticism constructively, but you can't expect them to walk all that far down it in a year.
  
  The key, like anything else in teaching or the rest of life, is individual attention to the students. You have to look at what's going on in their minds. And, of course, I strive to say this with the utmost humility: for me, this is a life skill that's going to take a lifetime... and sometimes it feels like it'll take two or three. But that's okay. I still feel like I can say the phrase and have the phrase be true, even when I strugle with doing it.
  
  What I have found very effective is to take the word "constructively" literally and see how far I can run with it. Consider the "stationary" points in the mind of a young student -- the things which are moving slow enough to be worth directing. Some of them are already constructed. They're stationary things like facts and beliefs which are already there. You can't constructively criticize those, because they're already constructed. They're done. All you can do to change them is be destructive. All you can do is tear them down and then try to show them what they should build up in its place. Doing so is certainly part of teaching, but it's not "constructive criticism."
  
  The other stationary point is more interesting, and far harder to see. These are the energetic holes in their lives where something could be constructed. These happen during growing up, and they also happen when an individual decides one of their beliefs shouldn't be so solid and tears it up. They then hold onto that potential looking for something to build in its place. This is where constructive criticism is tremendously powerful. If you can resolve something in their mind just by suggesting somewhere to put their load, the students will rapidly accept your offer.
  
  Note that this version of constructive criticism requires something in their mind already -- a desire to construct. You have to look for where they want to construct things, and make it happen. Consider the following students:
  
  * **Alice** has already decided she's going to be a programmer when she grows up. Accordingly, she's already got a thirst to learn from you simply because you're the CS teacher. A student such as this may give you great opportunities for constructive criticism. You may be able to provide her "breadcrumbs" guiding her and refining her skills, each time just barely within her reach. You might suggest she look at design patterns, when the rest of the class is struggling over `private` vs `public`. Also, because she's already interested, she's going to be inspecting anything along her career path carefully. If you help her put something down, and it lands in the wrong place, she will unearth it and try again. Give her suggestions about how to shoot for the stars, and she'll construct a bridge to get there.
  * **Bob** is in the process of going through lots of life changes. Everything is in flux for him. Maybe his voice cracks, maybe his code doesn't compile on the latest release of RHEL. Bob might be interested in finding some stability from the course. Perhaps you can show him how programming can help him think in ways which anchors pieces of his life. Perhaps you can show him how programming is a stable life that he might enjoy. Give him suggestions about how to build rock-solid code which won't break.
  * **Charlie** is the outsider in this communication. He's just the football jock who got stuck in a CS course. Maybe he doesn't really need programming at all. However, he does need leadership skills. See if there's a way to structure a group project such that having a strong leader is useful, even if they're not all that strong at writing software. Perhaps there's some customer interactions that need to take place? I mean, we all know the customer is a mythical beast whose feet never touch the ground, right? As it turns out, in customer relationships, there's rarely a "right" answer nailed down in stone. Everything has some potential to change, which makes constructive criticism easier.
  * **Eve**. There's always an Eve. Slightly malicious, always trying to find ways to cheat. Eves are tough. That's why she's always trying to eavesdrop on our public key encryption. But everyone is [human](https://xkcd.com/177/). I'd say find your own way for dealing with each Eve, but if you can remember that they're human, it's certainly possible to make it work.
  
  
  ---
  
  ### Answer by username_25 on 2017-07-09. Score: 3
  
  There have been many great answers so far, so I'll be brief. The students of mine who have difficulty with accepting criticism are often in a "fixed mindset" rather than a "growth mindset", with terminology from [Carol Dweck](http://rads.stackoverflow.com/amzn/click/0345472322). Most of my students have been high achievers all their lives. Some have got their self-worth bound up with being "good at" computer science (this is a "fixed" mindset). For those, criticism is interpreted as an attack on their self-worth. The other answers are trying to give ways to phrase criticism so it won't be interpreted in this way. I propose, trying to change the students (switching them to "growth" mindsets), so that they realize that they can always get better, and view constructive criticism as a way to do so. This is obviously a lot more work, but I think it's possibly the most valuable thing we can really teach our students.
  
  Our college president is a big fan of this work of Dweck, so he made a campus-wide push to help students make this switch. They learn about Dweck's work during orientation, and then students are put into "advising circles" that meet once or twice a week for their first semester on campus. The circle has a faculty advisor, and 12 students. It's 1 credit (1/4 of a full course). The advisor can give students things to read, or journaling assignments. So far, it seems to be helping. Our retention rate is up, and there are fewer confrontational students. Generally speaking, if I have a problem student, I think one of the best ways to change his behavior is to put him in a situation where his peers point that he is the only one with a problem. The advising circles help with that.
  
  Incidentally, I think the president initiated this move with the writing program in mind. Many students are resistant to criticism about their writing skills, and humanities professors have been dealing with this forever. I'll bet there is a lot we can learn from them, and I wonder if they also have journals for humanities-educators, where we could read what they've come up with.
  
  > **Comments:**
  > **username_19**: It is probably worth trying to factor out "growth mindset" into a separate thread. Can you pose a question? "How can we transform students..." I don't know enough to take the lead on this.  
  > **username_25**: Thanks for the suggestion. Let me think about it a bit and see if I come up with a good question.  
  > **username_19**: You might want to visit [the classroom](https://chat.stackexchange.com/rooms/59174/the-classroom) to help formulate it.  
  > **username_0**: I think the answer should be left here. It's a great one.  
  
  ---
  
  ### Answer by username_29 on 2017-07-07. Score: 3
  
  I think this question boils down into two generic parts:
  
  1. How to criticise in a way that doesn't trigger defensive behaviour, and;
  2. How to teach them how to handle criticism
  
  I think the first port of call would be to bring up the subject of handling criticism *as a dedicated class session*, including *how to extract useful feedback from poor criticism*, and *how to make criticism* (which they would be expected to do in the event of a code review, both reviewer and reviewee). They're adults, bring them on the level of both giving and receiving, and they should understand both sides.
  
  On the other side of the fence, how to criticise I find boils down into two categories:
  
  1. Subjective (EG this could look nicer)
  2. Objective (EG if you don't implement this, it will crash, and bad things will happen)
  
  **Subjective**
  
  On subjective criticisms, I find making 'speculative' recommendations passively works best, especially with reasoning listed. So say Joey forces all his code onto a single line, you'd say:
  
  > Joey, I've noticed that in this code, everything is on a single line! I think maybe - just a suggestion - having it on multiple lines might make it easier for other people to read.
  
  Joey has a couple of choices here. He can consider you've got a fair point, and might go for it, or, better yet, Joey will present the list of arguments as to why he has it on a single line (maybe 'no-one else will see my code' or 'I'm doing a contest on fewest bytes used on code gold'). At which point you can either explain why not building it for other people in mind is bad, or concede there is a reasoning behind it.
  
  This approach I find is excellent in team situations because the suggestions aren't forced, and it allows people to argue for/against a particular criticism. A dialogue occurs, instead of an argument.
  
  **Objective**
  
  This is where real problems begin. It's not because Joey has made an error, but if he continues with the error, stuff will catch on fire, the world is going to end and goto loops will become fashionable again. As a result, you're required to put your foot down.
  
  Before approaching, I find it works extremely well if the opening dialogue starts 'this is nothing personal, *but*...'. Psychologically, people think it's reverse psychology and thus terrible, but when you point to the code, this helps reinforce it's actually not.
  
  The criticism should be kept short, matter-of-fact 'if this happens it will do this' (if this has no try-catch and it throws an exception, the stack is going to crash and the system will go boom). Explain what-why and how to fix it.
  
  You can help reduce the sense of it being a personal failure (the main driver of being defensive) by either indicating it's a common problem or that it's a hard problem to spot. Joey might still get defensive, however: trick is to not rise to the argument.
  
  So, for example:
  
  > This is nothing personal, but, in line 232 of main.cpp, I've noticed that a try-catch statement is missing, which means exceptions are not being handled. If an exception isn't handled here, function ProcessArray might throw a memory allocation error which will cause the program to crash.
  
  Joey might defensively respond:
  
  > But on modern machines a memory allocation error is bound to never occur, so there's no need for a try-catch statement. Besides, I'm doing it for readability!
  
  At which point you sidestep the approaching argument, and simply return to matter-of-fact and a clean exit:
  
  > Good programming standards dictate that programs gracefully exit in the event of a major error, as crashing might impact the systems, if any, that rely upon it, especially to not crash. Operating Systems are a prime example of this. You might find a different workaround for this problem.
  
  I find some people hate being told what to do, and will spurn it even if it's the most logical choice. By alerting Joey to the problem, the solution, the reasons for that solution and the fact there might be other solutions, allows Joey to see the problem as an impersonal thing for him to solve (he didn't create the mem alloc error: he has to solve it), he has one known solution, and the freedom to research other unknown solutions.
  
  Joey can either see your solution as the easiest, might devise his own solution (which might be surprising - as a student, he should be learning, not merely copying), or might just choose to ignore it, in which case he suffers the consequences (bonus points if you can create a scenario that causes the error), including any subsequent markdowns on program's performance.
  
  **Final trick**
  
  If you want to be really hands off, there is one question that will get most people to reconsider a piece or line of code that doesn't require explanation:
  
  **What happens if** ...
  
  What happens if this ProcessArray hits a mem alloc error?
  
  What happens if this switch statement encounters an unknown case?
  
  etc
  
  
  ---
  
  ### Answer by username_12 on 2017-07-05. Score: 2
  
  I don't see why the same practices in the industry wouldn't apply to students. Professionals don't come pre-loaded with firmware to handle code-***reviews*** :) Here's been some of my experiences both giving and receiving code reviews:
  
  1. Prove you're right if telling someone they're wrong. Making a baseless assertion up-front is equivalent to, "I told you so," until proven otherwise.
  2. Show how the code will break if you think it will break. Don't just spout rhetoric in favor of different way to do it.
  3. Don't add your improvements to the list of changes needed. Keep necessary changes and improvements separate. If the coder likes your improvements, they will implement them.
  4. Appeal to their vanity by showing them how you can make their code even better instead of showing all its pitfalls. Learning new tricks is easier than losing bad habits.
  5. If you think something is wrong but you can't prove it, ask questions about its use instead of making assumptions. Even a solid educated guess gone-wrong can make a code review less constructive from that point on, and waste your time in the process.
  
  ### edit:
  
  Emphasis on code-***reviews***. [username_13](https://cseducators.stackexchange.com/username_8/124/username_13) brings up some good points when taking into consideration more in-depth criticism of code in the form of code-***audits***. These steps above are not the steps I would take for a code-audit.
  
  In regards to the main difference between the two and how to interact with people, I would say it has more to do with understanding the core intent of the code and figuring out where it falls short and coming up with more elegant solutions. For example, someone might accidentally re-invent something from C++11's `<algorithm>` library to help sort something from their class. In a code-review, I would mention this and advise you to remove it and replace it, but in an *audit*, I would *tell* you to fix it and remove the redundant code, because of the conversation's scope and the relationship's connotation.
  
  If I'm auditing your code, it's usually because of one of these reasons:
  
  1. It was requested ad-hoc for no specified reason
  2. Critical/frequent problems originating from a certain module or modules too often
  3. It was scheduled
  4. It was requested by the dev
  
  It's *usually* #4 and if you're playing with some fast and loose code cowboys, #2. So, in both of those scenarios you're basically the mentor/master and less of a peer. You're not there for the thumbs up/down, you're there to *take charge* and in some cases, *teach*.
  
  ### edit 2:
  
  Expanding on code audits and analysis as well as quality, I feel the living legend John Carmack does a good job describing it:
  
  > *The **most important** thing I have done as a programmer in **recent years***
  > *is to aggressively **pursue static code analysis***. Even more valuable
  > than the hundreds of serious bugs I have prevented with it is the
  > change in mindset about the way I view software reliability and code
  > quality.
  >
  > *It is important to say right up front that **quality isn't everything***,
  > and acknowledging it isn't some sort of moral failing. ***Value is what
  > you are trying to produce***, and quality is only one aspect of it,
  > intermixed with cost, features, and other factors. There have been
  > plenty of hugely successful and highly regarded titles that were
  > filled with bugs and crashed a lot; pursuing a Space Shuttle style
  > code development process for game development would be idiotic. ***Still,***
  > ***quality does matter***.
  
  * Original publication URL: <http://altdevblogaday.com/2011/12/24/static-code-analysis/>
  * Working "reprint" as on 2017: <http://www.gamasutra.com/view/news/39328/InDepth_Static_Code_Analysis.php>
  
  > **Comments:**
  > **username_13**: If you use these practices in industry, you're making bad software. My experience is in security, where we take quality seriously — your industry may be more ok with bugs. There are many, many cases where useful review feedback is “I can't see a bug, but the way you're writing it is dodgy, you should write clearer code” (with specifics as to how it's dodgy and how to make it clear of course). This comes from experience, not from pointing out a specific defect. It should be up to the coder to prove their code correct, not up to the reviewer to prove it wrong.  
  > **username_12**: So your diverging experience makes mine "bad software"? While I appreciate your input on the matter, you're making generalizations from an admitted point of specialty. If you have to ask if other parts of the industry care about bugs less than security, I don't know what to tell you other than yes, the industry in-general is going to care less about bugs than the security layers, _naturally_, with few but notable exceptions. Lastly, it's the coder's _unit tests_ that proves their code works. CR is _not_ the place to prove your code works, but proves it passes muster.  
  > **username_0**: +1 for "showing them how you can make their code even better"  
  > **username_13**: @username_12 Unit tests prove that the code works *in some cases*, which is a far cry from the code working. I'm aware that some parts of the industry don't care about quality. I don't want to train the next generation of programmers in that spirit.  
  > **username_12**: While apathy can lead to bugs, the existence of bugs is not proof of apathy. I said they care _less_, not that they don't care, and yes, code reviews are _not_ where you prove your code works. Unit tests, integration tests, functional tests/sample apps, you name it; that's where you verify code _works_. If you're deep-diving the code for bug and security analysis, you're describing a _code audit_, not a code review. They're quite different in their scope of responsibility and depth of analysis.  
  > **username_12**: Btw, I'm not trying to brow-beat you on the objective importance of quality in code. It's _very_ important, but it's not everything _all the time_. You work in security, so of course you'd be biased about it, and you can't help that easily. I wouldn't expect it otherwise. Medical equipment, security layers, aviation systems, weapons systems, automated vehicle solutions -- those things are life & death code, and that stuff gets its own umbrella of quality requirements well outside the normal bounds of responsibility of code quality. I would never discourage quality code.  
  > **username_12**: And lastly, I usually take off kid-gloves for code-audits. There's no point in not pointing out flaws and vulnerabilities when someone requests in-depth analysis of your code. How I interact with someone during an audit is not the same as a review, so if I were to take your feedback and put in the scope of an audit, I believe we would be in agreement on the level of coverage and type of feedback returned.  
  
  ---
  
  ### Answer by username_14 on 2017-07-06. Score: 2
  
  Don't actually do it. Often students code with time limits and/or when they are tired. This means that some implementations are done because they're faster to implement or because changing the current implementation would require too much time, or the student didn't even stop to think about other implementations.
  
  With that said, instead of giving a critique, provide a suggestion. Ask what led to that implementation, and (most of the times) they'll realize they could have done differentely in x,y,z. Then, ask what they feel about another implementation and its pros/cons and what could be used.
  
  If the goal is to have a student learn to code, help him get his thinking process in order, not his code.
  
  > **Comments:**
  > **username_4**: I feel like you're drawing a distinction without a difference here, unless you define what you mean by these terms. Nevertheless, we are always glad to have a new voice join us here. Welcome to [cseducators.se]!  
  > **username_14**: I simply feel that the best way to learn is by 'learning' rather than being taught to. Exposing flaws and alternatives stimulates critical thinking and would hardly be considered offensive by anyone  
  
  ---
  
  ### Answer by username_15 on 2017-07-06. Score: -1
  
  To borrow from Agile practice, you can adapt a form of the
  ***[Prime Directive](https://martinfowler.com/bliki/PrimingPrimeDirective.html)***.
  
  Always lead with it before looking at the product/code/process. It can feel repetitive, and even elementary. So it helps to
  rotate the reader of the quote, and open it to team discussion with new members.
  
  Its value grew and became more appreciated every time a retrospective
  revolved around a significant incident/bug/crisis. It gets the team
  past **blame**, toward the mindset of self-improvement. Before learning the prime directive, I experienced the blame aspect of code reviews consistently.
  
  **Edit:**
  Adding the [quote here](http://www.retrospectives.com/pages/retroPrimeDirective.html):
  
  > Regardless of what we discover, we understand and truly believe that everyone did the best job they could, given what they knew at the time, their skills and abilities, the resources available, and the situation at hand.
  
  The purpose as I understand it is to
  
  1. Create a **Safe Zone**. Nothing leaves the room. Eliminate fear.
  2. Treat the code as a product of the team, not one engineer.
  3. Action not attitude. Focus team energy on productive analysis and improvement
  
  ### Feedback
  
  As mentioned by Ben-I. In a lot of ways, code reviews are feedback (to the team). In feedback, there is an opening to achieve alignment.
  [Thanks for the Feedback p.232, Stone&Heen](http://stoneandheen.com/)
  
  > The opening is important because it sets the conversation's tone and trajectory.
  
  and further
  
  > You're not telling the feedback giver what they can or can't say; you're working to clarify the mutual purpose of the conversation and suggesting a two-way exploration. This helps you get aligned for the rest of the conversation.
  
  Also in feedback, both giving/receiving benefit from practice. In the same way it helps improve your speech delivery, Toastmasters utilize a Evaluator role to practice judging speakers. Have students practice *giving*, and *performing* code reviews.
  
  > **Comments:**
  > **username_13**: You mean, start every review by “… we understand and truly believe that everyone did the best job they could …”? If I was at the receiving end of this, I'd feel like you were saying “you did a bad job, but it's ok, it's just because you're an idiot”. It doesn't get the team past blame, quite the contrary.  
  > **username_15**: > We see things not as they are, but as we are - Anaïs Nin, various  
  
  ---
  
  