{"id":57,"date":"2022-02-12T03:00:31","date_gmt":"2022-02-12T03:00:31","guid":{"rendered":"https:\/\/blogs.oregonstate.edu\/donoblog\/?p=57"},"modified":"2022-02-12T03:05:46","modified_gmt":"2022-02-12T03:05:46","slug":"code-review-midnight","status":"publish","type":"post","link":"https:\/\/blogs.oregonstate.edu\/donoblog\/2022\/02\/12\/code-review-midnight\/","title":{"rendered":"Code Review Midnight"},"content":{"rendered":"\n<p>This week, I had a code review with not 1&#8230;.not 2&#8230;.but <strong>9 developers<\/strong>, at the same time. My first code review in a professional environment! This was part of the <a href=\"https:\/\/blogs.oregonstate.edu\/donoblog\/2022\/02\/05\/interview-with-an-engineer\/\">C++ Study Group I talked about joining last week<\/a>. While terrifying, the experience was also very enlightening. I can&#8217;t post the code, so I&#8217;ll do my best to generalize the kinds of feedback I got and my general thoughts.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><strong>More Comments!<\/strong> Before the meeting, I reviewed my code to make sure it was relatively self-explanatory. I thought my variables were well-named, my comments explained intent, and my functions were small enough to be easy to follow.<br><br>I quickly realized that I largely underestimated how much explaining I&#8217;d have to do on the spot. What do these nested loops do? Why are you declaring this variable at this scope? Why are you using an iterator here?<br><br>My best analogy for the experience is: it&#8217;s like making a chocolate cake. I had spent hours studying the recipe, working with the batter, making test cakes, and then I brought my best cake to show the other chefs. But when I arrived, I just showed them the finished cake and expected them to understand. What I really needed to bring was the recipe with all my notes. Next time: more comments!<br><\/li><li><strong>Always Ask &#8220;Why&#8221;?<\/strong> As we looked through the code, the group wanted to know why I made certain choices, on what I considered very basic decisions like: <br><br>&gt; Initializing variables<br>&gt; Using cout instead of printf<br>&gt; Why I used &#8220;\\n&#8221; instead of endl <br><br>I didn&#8217;t have good answers for these questions (partially because I&#8217;m not a strong C++ programmer) when I should have.<br><br>Just because something works doesn&#8217;t mean it&#8217;s the best choice. Next time: I&#8217;ll research the functions and methods I&#8217;m using to see if it&#8217;s the best choice for my code.<br><\/li><li> <strong>Full-Time Developers Know A LOT. (and they don&#8217;t always agree)<\/strong> Almost every step along the way, the developers introduced me to syntax and logic that I hadn&#8217;t even considered when writing the code. I realized how powerful it is to get that many diverse perspectives in the same place to compare notes.<br><br>The most interesting part of this was that they didn&#8217;t all agree on what the right choices were at each step. Everyone had their own preference that suited their coding style. Some developers had matter-of-fact answers that &#8220;method A&#8221; was demonstrably faster than &#8220;method B&#8221;, but another developer would come back with a rebuttal about readability or reuseability of code, or whether a specific method that was too obscure to be understood by most developers.<br><br>The one thing they all agreed on: your indenting must be consistent! While there are different indenting and bracket placement preferences, this should be the same across your code. <br><br>Next time: I hope to have more coding experience so I can be part of the debate! <br><\/li><li><strong>Fewer Variables = Better.<\/strong> One of the best general comments I got was:<br><br>Finding ways to eliminate variables or declare them as constants is almost always a good choice.<br><br>Looking through my code, I realized I sometimes declare variables as a note to myself or clarification why a certain value goes in a specific function. I realized if I write better comments, I can fix this behavior and write cleaner code that doesn&#8217;t require extra variables, saving me the time when I come back to the code of having to figure out what those variables are doing, and why they are there. Next time: fewer variables!<\/li><\/ol>\n\n\n\n<p>This is a post I expect to come back to in the next few months as I work more on my C++ proficiency. I hope some of these notes are useful to you too!<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This week, I had a code review with not 1&#8230;.not 2&#8230;.but 9 developers, at the same time. My first code review in a professional environment! This was part of the C++ Study Group I talked about joining last week. While terrifying, the experience was also very enlightening. I can&#8217;t post the code, so I&#8217;ll do&hellip; <a href=\"https:\/\/blogs.oregonstate.edu\/donoblog\/2022\/02\/12\/code-review-midnight\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":11899,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-57","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.oregonstate.edu\/donoblog\/wp-json\/wp\/v2\/posts\/57","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.oregonstate.edu\/donoblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.oregonstate.edu\/donoblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/donoblog\/wp-json\/wp\/v2\/users\/11899"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/donoblog\/wp-json\/wp\/v2\/comments?post=57"}],"version-history":[{"count":8,"href":"https:\/\/blogs.oregonstate.edu\/donoblog\/wp-json\/wp\/v2\/posts\/57\/revisions"}],"predecessor-version":[{"id":65,"href":"https:\/\/blogs.oregonstate.edu\/donoblog\/wp-json\/wp\/v2\/posts\/57\/revisions\/65"}],"wp:attachment":[{"href":"https:\/\/blogs.oregonstate.edu\/donoblog\/wp-json\/wp\/v2\/media?parent=57"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/donoblog\/wp-json\/wp\/v2\/categories?post=57"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/donoblog\/wp-json\/wp\/v2\/tags?post=57"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}