{"id":4803,"date":"2017-02-16T16:26:19","date_gmt":"2017-02-16T16:26:19","guid":{"rendered":"https:\/\/blog-stg.cheesecakelabs.com\/blog\/code-review-easier-better-faster-stronger\/"},"modified":"2022-07-01T17:44:13","modified_gmt":"2022-07-01T17:44:13","slug":"code-review-easier-better-faster-stronger","status":"publish","type":"post","link":"https:\/\/blog-stg.cheesecakelabs.com\/br\/code-review-easier-better-faster-stronger\/","title":{"rendered":"Code Review: Easier Better Faster Stronger"},"content":{"rendered":"<p style=\"text-align: left;\"><span style=\"font-weight: 400;\">Yes, you read it right. I took the liberty to adapt <\/span><a href=\"https:\/\/www.youtube.com\/watch?v=gAjR4_CbPpQ\"><span style=\"font-weight: 400;\">Daft Punk&#8217;s song title<\/span><\/a><span style=\"font-weight: 400;\"> to talk about <\/span><b>code review<\/b><span style=\"font-weight: 400;\">. As I write this, I&#8217;m wondering &nbsp;if it is going to pass the thorough examination of the chief editor, but I like how the title sounds (and it really describes how a Pull Request should be). And you see, even this harmless <strong>piece of text is going over a <\/strong><\/span><del><strong>rvesoin<\/strong><\/del><span style=\"font-weight: 400;\"><strong>&nbsp;revision process<\/strong> before you can have the chance to be struck by my insights, so <strong>why shouldn&#8217;t we do the same with our code<\/strong>?<\/span><\/p>\n<p style=\"text-align: left;\"><!--more--><\/p>\n<p><span style=\"font-weight: 400;\">Code review is the process of having a peer developer reading your code after it&#8217;s done or during development time (pair-programming)<\/span>. The main goals are to find <strong>overlooked mistakes<\/strong>, guarantee the maintenance of the<strong> code style guidelines<\/strong> and discover more <strong>elegant ways to solve<\/strong> the same problem, taking into account scalability and performance, for instance. The result is software with <strong>better quality<\/strong> and <strong>wider involvement<\/strong> of the development team. Having your code inspected by someone else has many positive impacts:<\/p>\n<ol>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><strong>Find errors<\/strong>, possible vulnerabilities and under-performing code before it reaches the final user (or even before it reaches QA, depending on your process).<br \/>\n<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><strong>Spread knowledge<\/strong> among all participants, making sure there are at least two people that know what&#8217;s going on with that chunk of code.<br \/>\n<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><strong>Encourage constructive discussion<\/strong> with other developers: when people dive deeper into the code as a group, they tend to write better code as a group.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><strong>Distribute responsibility and ownership<\/strong>. This way, nobody has to feel the pressure of failure on their own and everybody takes credit when it succeeds.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">It&#8217;s an excellent way for <strong>junior developers to learn<\/strong> with more seasoned professionals.<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">Despite all these advantages, a lot of developers still shiver when they are assigned to a Pull Request. Code review is many times <strong>taken as unnecessary, inefficient and deadly boring<\/strong>. Don&#8217;t get me wrong: I understand this is sometimes the case. What I want to point out is that <strong>the problem usually isn&#8217;t the code review itself<\/strong>, but the process involved. Picture the following scenario:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">You see a new Pull Request assigned to you. At first, you have no idea what&#8217;s it all about. The title reads: &#8220;Improvements and refactor&#8221;. You click on the link and see an ocean of green and red marks: four thousand additions, a thousand deletions. You don&#8217;t freak out, start full gas: &#8220;comment it, scroll it, improve it, code it&#8221; <em>(read with robotic voice)<\/em>. Soon you are bored, comments are less and less frequent, and the code review loses its purpose.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-4112 size-full\" src=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2017\/02\/sad.gif\" alt=\"\" width=\"224\" height=\"161\"><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">This is not because the revision process doesn&#8217;t work at all, it&#8217;s simply because <strong>it&#8217;s being done the wrong way<\/strong>. Here are some principles we try to follow at our best here at Cheesecake Labs to <strong>improve code review quality<\/strong>:<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><strong>Keep your PR focused on its goal:<\/strong> if you just want to fix a typo, that&#8217;s all you&#8217;re going to do. Don&#8217;t take the chance to do small refactorings here and there, they are a big source of distraction for those reviewing your code.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><strong>Write meaningful commit messages and PR titles:<\/strong> give people some context on what are you trying to achieve with your code.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Try your best to <strong>keep it under 500 lines<\/strong> between additions and deletions: less lines of code means less time reviewing it (and a more concentrated reviewer as a result).<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><strong>Use linting and automated tests:<\/strong> the reviewer shouldn\u2019t waste time with what the computer could have done.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><strong>Keep related code as close as possible:<\/strong> if two files have related code \u2013 let&#8217;s say the view and the controller \u2013 save them close to each other, in the same directory if possible. This way they are going to appear one right after the other on the code diff.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><strong>Keep the trailing comma in multiline literals<\/strong> (arrays, objects, dictionaries): it may sound small, but it can save a considerable amount of time with <\/span><span style=\"font-weight: 400;\"><a href=\"https:\/\/www.puppetcookbook.com\/posts\/trailing-commas.html\">merge conflicts<\/a>. As a plus, it appears as a one-line change on versioning diff, instead of two.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><strong>Follow a code style pattern:<\/strong> our brain is trained to understand patterns. If you always structure imports, docstrings, breaks and naming the same way, your code will be less tiring and easier to read.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Last but not least: <strong>don&#8217;t take things personally<\/strong>. Unless someone is really rude with comments, everything is annotated to improve the product&#8217;s overall quality. You can still be friends and have a beer together later.<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">Here at Cheesecake Labs we take code review as a <strong>core part of our culture<\/strong>. We use it to have <strong>awesome conversations<\/strong> among devs, <strong>learn new technologies<\/strong> with more experienced peers, <strong>let others know<\/strong> how we solve problems and most importantly: deliver great software <strong>as a team<\/strong>.<\/span><\/p>\n<p>By the way, want to learn Pull Request submission best practices? Check out this post that&nbsp;my friend Iacami wrote about it: <a href=\"https:\/\/blog-stg.cheesecakelabs.com\/git-etiquette-submitting-pull-request\/\">Git Etiquette: Submitting a Pull Request<\/a>.<\/p>\n<p><em>Cover Image: Adapted from &#8220;Daft Punk by Shaun Laakso&#8221;. <a href=\"https:\/\/creativecommons.org\/licenses\/by-nc\/4.0\/legalcode\">Creative Commons Attribution-NonCommercial 4.0<\/a><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Yes, you read it right. I took the liberty to adapt Daft Punk&#8217;s song title to talk about code review. As I write this, I&#8217;m wondering &nbsp;if it is going to pass the thorough examination of the chief editor, but I like how the title sounds (and it really describes how a Pull Request should [&hellip;]<\/p>\n","protected":false},"author":65,"featured_media":9025,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[471,344],"tags":[1153],"class_list":["post-4803","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-engenharia","category-opiniao","tag-tag-code-br"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Code Review: Easier Better Faster Stronger | Cheesecake Labs<\/title>\n<meta name=\"description\" content=\"Code Review is all about evaluating other people&#039;s code, resulting in software with better quality and wider involvement of the development team.\" \/>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"pt_BR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Code Review: Easier Better Faster Stronger | Cheesecake Labs\" \/>\n<meta property=\"og:description\" content=\"Code Review is all about evaluating other people&#039;s code, resulting in software with better quality and wider involvement of the development team.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog-stg.cheesecakelabs.com\/br\/code-review-easier-better-faster-stronger\/\" \/>\n<meta property=\"og:site_name\" content=\"Cheesecake Labs\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/cheesecakelabs\" \/>\n<meta property=\"article:published_time\" content=\"2017-02-16T16:26:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-01T17:44:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2017\/02\/Banner_betterforeview.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2000\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Cheesecake Labs\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@cheesecakelabs\" \/>\n<meta name=\"twitter:site\" content=\"@cheesecakelabs\" \/>\n<meta name=\"twitter:label1\" content=\"Escrito por\" \/>\n\t<meta name=\"twitter:data1\" content=\"\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. tempo de leitura\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/blog-stg.cheesecakelabs.com\/br\/code-review-easier-better-faster-stronger\/\",\"url\":\"https:\/\/blog-stg.cheesecakelabs.com\/br\/code-review-easier-better-faster-stronger\/\",\"name\":\"Code Review: Easier Better Faster Stronger | Cheesecake Labs\",\"isPartOf\":{\"@id\":\"https:\/\/blog-stg.cheesecakelabs.com\/br\/#website\"},\"datePublished\":\"2017-02-16T16:26:19+00:00\",\"dateModified\":\"2022-07-01T17:44:13+00:00\",\"author\":{\"@type\":\"person\",\"name\":\"Bernardo Smaniotto\"},\"description\":\"Code Review is all about evaluating other people's code, resulting in software with better quality and wider involvement of the development team.\",\"breadcrumb\":{\"@id\":\"https:\/\/blog-stg.cheesecakelabs.com\/br\/code-review-easier-better-faster-stronger\/#breadcrumb\"},\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/blog-stg.cheesecakelabs.com\/br\/code-review-easier-better-faster-stronger\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/blog-stg.cheesecakelabs.com\/br\/code-review-easier-better-faster-stronger\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/blog-stg.cheesecakelabs.com\/br\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Code Review: Easier Better Faster Stronger\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/blog-stg.cheesecakelabs.com\/br\/#website\",\"url\":\"https:\/\/blog-stg.cheesecakelabs.com\/br\/\",\"name\":\"Cheesecake Labs\",\"description\":\"Empresa de desenvolvimento e design de aplicativos mobile &amp; web que est\u00e1 reinventando o desenvolvimento de produtos com times remotos. N\u00f3s desenvolvemos aplicativos iOS, Android e aplica\u00e7\u00f5es Web com as melhores empresas dos EUA, do Brasil e do mundo.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/blog-stg.cheesecakelabs.com\/br\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"pt-BR\"},{\"@type\":\"Person\",\"name\":\"Bernardo Smaniotto\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\/\/blog-stg.cheesecakelabs.com\/br\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2016\/11\/bernardo-300x300.jpg\",\"contentUrl\":\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2016\/11\/bernardo-300x300.jpg\",\"caption\":\"Bernardo Smaniotto\"},\"description\":\"10 years of experience in Marketing and Sales in the Technology sector. My main purpose is help, support and structure efficient operations and also develop independent and multidisciplinary teams.\",\"url\":\"https:\/\/blog-stg.cheesecakelabs.com\/br\/\/autor\/bernardo-smaniotto\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Code Review: Easier Better Faster Stronger | Cheesecake Labs","description":"Code Review is all about evaluating other people's code, resulting in software with better quality and wider involvement of the development team.","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"pt_BR","og_type":"article","og_title":"Code Review: Easier Better Faster Stronger | Cheesecake Labs","og_description":"Code Review is all about evaluating other people's code, resulting in software with better quality and wider involvement of the development team.","og_url":"https:\/\/blog-stg.cheesecakelabs.com\/br\/code-review-easier-better-faster-stronger\/","og_site_name":"Cheesecake Labs","article_publisher":"https:\/\/www.facebook.com\/cheesecakelabs","article_published_time":"2017-02-16T16:26:19+00:00","article_modified_time":"2022-07-01T17:44:13+00:00","og_image":[{"width":2000,"height":720,"url":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2017\/02\/Banner_betterforeview.png","type":"image\/png"}],"author":"Cheesecake Labs","twitter_card":"summary_large_image","twitter_creator":"@cheesecakelabs","twitter_site":"@cheesecakelabs","twitter_misc":{"Escrito por":null,"Est. tempo de leitura":"4 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/blog-stg.cheesecakelabs.com\/br\/code-review-easier-better-faster-stronger\/","url":"https:\/\/blog-stg.cheesecakelabs.com\/br\/code-review-easier-better-faster-stronger\/","name":"Code Review: Easier Better Faster Stronger | Cheesecake Labs","isPartOf":{"@id":"https:\/\/blog-stg.cheesecakelabs.com\/br\/#website"},"datePublished":"2017-02-16T16:26:19+00:00","dateModified":"2022-07-01T17:44:13+00:00","author":{"@type":"person","name":"Bernardo Smaniotto"},"description":"Code Review is all about evaluating other people's code, resulting in software with better quality and wider involvement of the development team.","breadcrumb":{"@id":"https:\/\/blog-stg.cheesecakelabs.com\/br\/code-review-easier-better-faster-stronger\/#breadcrumb"},"inLanguage":"pt-BR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog-stg.cheesecakelabs.com\/br\/code-review-easier-better-faster-stronger\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/blog-stg.cheesecakelabs.com\/br\/code-review-easier-better-faster-stronger\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blog-stg.cheesecakelabs.com\/br\/"},{"@type":"ListItem","position":2,"name":"Code Review: Easier Better Faster Stronger"}]},{"@type":"WebSite","@id":"https:\/\/blog-stg.cheesecakelabs.com\/br\/#website","url":"https:\/\/blog-stg.cheesecakelabs.com\/br\/","name":"Cheesecake Labs","description":"Empresa de desenvolvimento e design de aplicativos mobile &amp; web que est\u00e1 reinventando o desenvolvimento de produtos com times remotos. N\u00f3s desenvolvemos aplicativos iOS, Android e aplica\u00e7\u00f5es Web com as melhores empresas dos EUA, do Brasil e do mundo.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog-stg.cheesecakelabs.com\/br\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"pt-BR"},{"@type":"Person","name":"Bernardo Smaniotto","image":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/blog-stg.cheesecakelabs.com\/br\/#\/schema\/person\/image\/","url":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2016\/11\/bernardo-300x300.jpg","contentUrl":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2016\/11\/bernardo-300x300.jpg","caption":"Bernardo Smaniotto"},"description":"10 years of experience in Marketing and Sales in the Technology sector. My main purpose is help, support and structure efficient operations and also develop independent and multidisciplinary teams.","url":"https:\/\/blog-stg.cheesecakelabs.com\/br\/\/autor\/bernardo-smaniotto\/"}]}},"_links":{"self":[{"href":"https:\/\/blog-stg.cheesecakelabs.com\/br\/wp-json\/wp\/v2\/posts\/4803","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog-stg.cheesecakelabs.com\/br\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog-stg.cheesecakelabs.com\/br\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog-stg.cheesecakelabs.com\/br\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/blog-stg.cheesecakelabs.com\/br\/wp-json\/wp\/v2\/comments?post=4803"}],"version-history":[{"count":1,"href":"https:\/\/blog-stg.cheesecakelabs.com\/br\/wp-json\/wp\/v2\/posts\/4803\/revisions"}],"predecessor-version":[{"id":10317,"href":"https:\/\/blog-stg.cheesecakelabs.com\/br\/wp-json\/wp\/v2\/posts\/4803\/revisions\/10317"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog-stg.cheesecakelabs.com\/br\/wp-json\/wp\/v2\/media\/9025"}],"wp:attachment":[{"href":"https:\/\/blog-stg.cheesecakelabs.com\/br\/wp-json\/wp\/v2\/media?parent=4803"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog-stg.cheesecakelabs.com\/br\/wp-json\/wp\/v2\/categories?post=4803"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog-stg.cheesecakelabs.com\/br\/wp-json\/wp\/v2\/tags?post=4803"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}