{"id":385,"date":"2010-02-16T10:07:11","date_gmt":"2010-02-16T17:07:11","guid":{"rendered":"https:\/\/simpleprogrammer.com\/?p=385"},"modified":"2018-02-23T15:42:10","modified_gmt":"2018-02-23T20:42:10","slug":"book-review-clean-code","status":"publish","type":"post","link":"https:\/\/simpleprogrammer.com\/book-review-clean-code\/","title":{"rendered":"Book Review: Clean Code"},"content":{"rendered":"<p><a href=\"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2010\/02\/cleancode.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-386\" title=\"cleancode\" alt=\"\" src=\"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2010\/02\/cleancode.jpg\" width=\"240\" height=\"240\" srcset=\"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2010\/02\/cleancode.jpg 240w, https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2010\/02\/cleancode-150x150.jpg 150w\" sizes=\"auto, (max-width: 240px) 100vw, 240px\" \/><\/a><\/p>\n<p>I recently completed reading the book <a href=\"http:\/\/www.amazon.com\/gp\/product\/0132350882\/ref=as_li_ss_tl?ie=UTF8&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0132350882&amp;linkCode=as2&amp;tag=makithecompsi-20\" target=\"_blank\">&#8220;Clean Code&#8221;<\/a> by <a href=\"http:\/\/www.amazon.com\/Robert-C.-Martin\/e\/B000APG87E\/?_encoding=UTF8&amp;camp=1789&amp;creative=390957&amp;linkCode=ur2&amp;tag=makithecompsi-20\" target=\"_blank\">Robert Martin<\/a>. \u00a0I have to say that this one is a keeper. \u00a0I would highly recommend getting this book and keeping this one for <a href=\"https:\/\/simpleprogrammer.com\/2009\/12\/08\/great-developers-are-librarians\/\">your library<\/a>.<\/p>\n<p>This book is very much in the spirit of <a href=\"http:\/\/www.amazon.com\/gp\/product\/0735619670\/ref=as_li_ss_tl?ie=UTF8&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0735619670&amp;linkCode=as2&amp;tag=makithecompsi-20\" target=\"_blank\">&#8220;Code Complete&#8221;<\/a> in that it talks about software construction at a pretty low level. \u00a0The book is written from a Java perspective, but easily most of the ideas transcend a particular language. \u00a0It is very rare to come across books which have the potential to completely change the way a person thinks about writing code. \u00a0This is one of those books.<\/p>\n<p>One of the best things about this book is the hands on approach to making the code clean. \u00a0It is one thing to talk about how to make code better, but it is another thing to use real world code and show how it is transformed.<\/p>\n<p><strong>Good:<\/strong><\/p>\n<ul>\n<li>Great explanation of why clean code is important.<\/li>\n<li>Very detailed information on choosing good names.<\/li>\n<li>Excellent advice on function size and parameters.<\/li>\n<li>Very convincing chapter on why comments are usually bad vs writing code that expresses its intent.<\/li>\n<li>Unit testing advice, how to keep tests clean.<\/li>\n<li>Excellent coverage of concurrency problems and solutions.<\/li>\n<li>Real examples of refactoring and making code clean from real projects.<\/li>\n<li>Nice section on code smells and heuristics.<\/li>\n<\/ul>\n<p><strong>Bad:<\/strong><\/p>\n<p>Honestly, not much here at all&#8230; the only thing is a chapter on formatting which I found not that important, since most of us use auto-formatting rules in our IDEs.<\/p>\n<p><strong>What I learned<\/strong><\/p>\n<p>It&#8217;s hard to pick out all the little pieces of &#8220;ah ha&#8221; moments when reading this book, but here are a few in particular that stuck out to me. \u00a0I may have known some of these things, but reading them in print made them so much more clear and concrete.<\/p>\n<p>Methods should try to not have parameters. \u00a0The less parameters the better. \u00a0I kind of already knew this, but in this book it is made really clear why having 1 parameter is so much better than having 2.<\/p>\n<p>Try not to overload methods taking different parameters. \u00a0When looking at some of the code examples here, I could very clearly see why having another method was better than an overload.<\/p>\n<p>I was relying on getter and setter methods in my code too much. \u00a0I learned that I should be thinking of a way to not have to use getter and setter methods by making the class do the work or moving parameters inside the class.<\/p>\n<p>I was thinking the more Java Doc or NDoc the better, but after reading the section on comments, I realized that having that hard and fast rule is not really good. \u00a0Now I am only going to use Java Doc or NDoc where it actually provides information, not just as a rule.<\/p>\n<p>Don&#8217;t return null. \u00a0This seems obvious, but I realized that instead of having to try and deal with null parameters, a much better strategy is to just never return null in your code so that you never have to try and deal with null.<\/p>\n<p>Several bits about concurrency. \u00a0It was really interesting to see why concurrency issues can occur from a byte code viewpoint. \u00a0I learned about a few places I didn&#8217;t realize that concurrency issues could occur and some good techniques for putting concurrency problems into a single class and not letting them leak into the entire application.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently completed reading the book &#8220;Clean Code&#8221; by Robert Martin. \u00a0I have to say that this one is a keeper. \u00a0I would highly recommend getting this book and keeping this one for your library. This book is very much in the spirit of &#8220;Code Complete&#8221; in that it talks about software construction at a&#8230;<\/p>\n","protected":false},"author":2,"featured_media":386,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[7215,148,264,54712,5895],"tags":[],"class_list":["post-385","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-book-review","category-design","category-learning","category-refactoring","category-self-improvement"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Book Review: Clean Code<\/title>\n<meta name=\"description\" content=\"A book review on Robert Martin&#039;s book, Clean Code. The review includes a list of the book&#039;s strengths and highlights some noteworthy insights.\" \/>\n<meta name=\"robots\" content=\"noindex, follow\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Book Review: Clean Code\" \/>\n<meta property=\"og:description\" content=\"A book review on Robert Martin&#039;s book, Clean Code. The review includes a list of the book&#039;s strengths and highlights some noteworthy insights.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/simpleprogrammer.com\/book-review-clean-code\/\" \/>\n<meta property=\"og:site_name\" content=\"Simple Programmer\" \/>\n<meta property=\"article:published_time\" content=\"2010-02-16T17:07:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-02-23T20:42:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2010\/02\/cleancode.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"240\" \/>\n\t<meta property=\"og:image:height\" content=\"240\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"John Sonmez\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"John Sonmez\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/book-review-clean-code\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/book-review-clean-code\\\/\"},\"author\":{\"name\":\"John Sonmez\",\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/#\\\/schema\\\/person\\\/1abc70edfb189184827740310672de67\"},\"headline\":\"Book Review: Clean Code\",\"datePublished\":\"2010-02-16T17:07:11+00:00\",\"dateModified\":\"2018-02-23T20:42:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/book-review-clean-code\\\/\"},\"wordCount\":577,\"commentCount\":3,\"image\":{\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/book-review-clean-code\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/simpleprogrammer.com\\\/wp-content\\\/uploads\\\/2010\\\/02\\\/cleancode.jpg\",\"articleSection\":[\"Book Review\",\"Design\",\"Learning\",\"Refactoring\",\"Self Improvement\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/simpleprogrammer.com\\\/book-review-clean-code\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/book-review-clean-code\\\/\",\"url\":\"https:\\\/\\\/simpleprogrammer.com\\\/book-review-clean-code\\\/\",\"name\":\"Book Review: Clean Code\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/book-review-clean-code\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/book-review-clean-code\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/simpleprogrammer.com\\\/wp-content\\\/uploads\\\/2010\\\/02\\\/cleancode.jpg\",\"datePublished\":\"2010-02-16T17:07:11+00:00\",\"dateModified\":\"2018-02-23T20:42:10+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/#\\\/schema\\\/person\\\/1abc70edfb189184827740310672de67\"},\"description\":\"A book review on Robert Martin's book, Clean Code. The review includes a list of the book's strengths and highlights some noteworthy insights.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/book-review-clean-code\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/simpleprogrammer.com\\\/book-review-clean-code\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/book-review-clean-code\\\/#primaryimage\",\"url\":\"https:\\\/\\\/simpleprogrammer.com\\\/wp-content\\\/uploads\\\/2010\\\/02\\\/cleancode.jpg\",\"contentUrl\":\"https:\\\/\\\/simpleprogrammer.com\\\/wp-content\\\/uploads\\\/2010\\\/02\\\/cleancode.jpg\",\"width\":240,\"height\":240,\"caption\":\"image of the book Clean Code\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/book-review-clean-code\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/simpleprogrammer.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Book Review: Clean Code\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/#website\",\"url\":\"https:\\\/\\\/simpleprogrammer.com\\\/\",\"name\":\"Simple Programmer\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/simpleprogrammer.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/#\\\/schema\\\/person\\\/1abc70edfb189184827740310672de67\",\"name\":\"John Sonmez\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/dc2f18dfa76e017566ce607de002d7abe4acfd5ec19a6db82c180b00867b8d94?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/dc2f18dfa76e017566ce607de002d7abe4acfd5ec19a6db82c180b00867b8d94?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/dc2f18dfa76e017566ce607de002d7abe4acfd5ec19a6db82c180b00867b8d94?s=96&d=mm&r=g\",\"caption\":\"John Sonmez\"},\"url\":\"https:\\\/\\\/simpleprogrammer.com\\\/author\\\/jsonmez\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Book Review: Clean Code","description":"A book review on Robert Martin's book, Clean Code. The review includes a list of the book's strengths and highlights some noteworthy insights.","robots":{"index":"noindex","follow":"follow"},"og_locale":"en_US","og_type":"article","og_title":"Book Review: Clean Code","og_description":"A book review on Robert Martin's book, Clean Code. The review includes a list of the book's strengths and highlights some noteworthy insights.","og_url":"https:\/\/simpleprogrammer.com\/book-review-clean-code\/","og_site_name":"Simple Programmer","article_published_time":"2010-02-16T17:07:11+00:00","article_modified_time":"2018-02-23T20:42:10+00:00","og_image":[{"width":240,"height":240,"url":"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2010\/02\/cleancode.jpg","type":"image\/jpeg"}],"author":"John Sonmez","twitter_card":"summary_large_image","twitter_misc":{"Written by":"John Sonmez","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/simpleprogrammer.com\/book-review-clean-code\/#article","isPartOf":{"@id":"https:\/\/simpleprogrammer.com\/book-review-clean-code\/"},"author":{"name":"John Sonmez","@id":"https:\/\/simpleprogrammer.com\/#\/schema\/person\/1abc70edfb189184827740310672de67"},"headline":"Book Review: Clean Code","datePublished":"2010-02-16T17:07:11+00:00","dateModified":"2018-02-23T20:42:10+00:00","mainEntityOfPage":{"@id":"https:\/\/simpleprogrammer.com\/book-review-clean-code\/"},"wordCount":577,"commentCount":3,"image":{"@id":"https:\/\/simpleprogrammer.com\/book-review-clean-code\/#primaryimage"},"thumbnailUrl":"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2010\/02\/cleancode.jpg","articleSection":["Book Review","Design","Learning","Refactoring","Self Improvement"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/simpleprogrammer.com\/book-review-clean-code\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/simpleprogrammer.com\/book-review-clean-code\/","url":"https:\/\/simpleprogrammer.com\/book-review-clean-code\/","name":"Book Review: Clean Code","isPartOf":{"@id":"https:\/\/simpleprogrammer.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/simpleprogrammer.com\/book-review-clean-code\/#primaryimage"},"image":{"@id":"https:\/\/simpleprogrammer.com\/book-review-clean-code\/#primaryimage"},"thumbnailUrl":"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2010\/02\/cleancode.jpg","datePublished":"2010-02-16T17:07:11+00:00","dateModified":"2018-02-23T20:42:10+00:00","author":{"@id":"https:\/\/simpleprogrammer.com\/#\/schema\/person\/1abc70edfb189184827740310672de67"},"description":"A book review on Robert Martin's book, Clean Code. The review includes a list of the book's strengths and highlights some noteworthy insights.","breadcrumb":{"@id":"https:\/\/simpleprogrammer.com\/book-review-clean-code\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/simpleprogrammer.com\/book-review-clean-code\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/simpleprogrammer.com\/book-review-clean-code\/#primaryimage","url":"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2010\/02\/cleancode.jpg","contentUrl":"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2010\/02\/cleancode.jpg","width":240,"height":240,"caption":"image of the book Clean Code"},{"@type":"BreadcrumbList","@id":"https:\/\/simpleprogrammer.com\/book-review-clean-code\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/simpleprogrammer.com\/"},{"@type":"ListItem","position":2,"name":"Book Review: Clean Code"}]},{"@type":"WebSite","@id":"https:\/\/simpleprogrammer.com\/#website","url":"https:\/\/simpleprogrammer.com\/","name":"Simple Programmer","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/simpleprogrammer.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/simpleprogrammer.com\/#\/schema\/person\/1abc70edfb189184827740310672de67","name":"John Sonmez","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/dc2f18dfa76e017566ce607de002d7abe4acfd5ec19a6db82c180b00867b8d94?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/dc2f18dfa76e017566ce607de002d7abe4acfd5ec19a6db82c180b00867b8d94?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/dc2f18dfa76e017566ce607de002d7abe4acfd5ec19a6db82c180b00867b8d94?s=96&d=mm&r=g","caption":"John Sonmez"},"url":"https:\/\/simpleprogrammer.com\/author\/jsonmez\/"}]}},"_links":{"self":[{"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/posts\/385","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/comments?post=385"}],"version-history":[{"count":0,"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/posts\/385\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/media\/386"}],"wp:attachment":[{"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/media?parent=385"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/categories?post=385"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/tags?post=385"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}