{"id":988,"date":"2018-07-22T15:38:35","date_gmt":"2018-07-22T10:08:35","guid":{"rendered":"http:\/\/www.rangakrish.com\/?p=988"},"modified":"2018-07-22T18:06:51","modified_gmt":"2018-07-22T12:36:51","slug":"book-review-design-patterns-in-modern-c","status":"publish","type":"post","link":"https:\/\/www.rangakrish.com\/index.php\/2018\/07\/22\/book-review-design-patterns-in-modern-c\/","title":{"rendered":"Book Review &#8211; Design Patterns in Modern C++"},"content":{"rendered":"<p><em><strong>Title: Design Patterns in Modern C++ &#8211; Reusable Approaches for Object-Oriented Software Design<\/strong><\/em><\/p>\n<p><em><strong>Author: Dmitri Nesteruk<\/strong><\/em><\/p>\n<p><em><strong>Publisher: Apress<\/strong><\/em><\/p>\n<p><em><strong>Year: 2018<\/strong><\/em><\/p>\n<p>Luck has been on my side for the past few weeks; I have been getting access to nice books to read. I wrote about <a href=\"http:\/\/www.rangakrish.com\/index.php\/2018\/07\/08\/book-review-the-modern-c-challenge\/\" target=\"_blank\" rel=\"noopener\"><em><strong>The<\/strong><\/em>\u00a0<em><strong>Modern C++ Challenge<\/strong><\/em><\/a> in my last post. Today, I am going to review another nice book.<\/p>\n<p>Since the original <em><strong>GoF <a href=\"https:\/\/en.wikipedia.org\/wiki\/Design_Patterns\" target=\"_blank\" rel=\"noopener\">book<\/a><\/strong><\/em>, much has been written and talked about <em><strong>Design Patterns<\/strong><\/em>. They are the bread and butter of every serious software developer. The C++ examples given in the <em><strong>GoF<\/strong><\/em> book are somewhat outdated now because the language itself has evolved significantly over this long period. So it is refreshing to see a book that focusses entirely on <em><strong>Design Patterns<\/strong><\/em> using the latest C++ standard.<\/p>\n<p>The presentation format of the various design patterns is different in this book compared to the original <em><strong>GoF<\/strong><\/em> book. In the latter, each pattern is explained using various sections such as <em><strong>Intent<\/strong><\/em>, <em><strong>Motivation<\/strong><\/em>, <em><strong>Applicability<\/strong><\/em>, and so on. In this book, however, that template is not followed. It is somewhat of a linear presentation with several examples. I find this acceptable because the book\u2019s purpose is not to teach design patterns, but to present the classic patterns in the context of the current C++ standard. What this means is that if you are new to design patterns, then you are better off starting with the <em><strong>GoF<\/strong><\/em> book and then coming back to this book for the specifics of C++ implementation. I doubt if anyone can do better than the <em><strong>GoF<\/strong><\/em> book in terms of explaining the concepts.<\/p>\n<p>One thing I like about this book is that the author describes important C++ concepts (e.g. <a href=\"https:\/\/en.wikipedia.org\/wiki\/Curiously_recurring_template_pattern\" target=\"_blank\" rel=\"noopener\"><em><strong>Curiously Recurring Template Pattern<\/strong><\/em><\/a>) and also the <a href=\"https:\/\/en.wikipedia.org\/wiki\/SOLID\" target=\"_blank\" rel=\"noopener\"><em><strong>SOLID<\/strong><\/em><\/a> design principles in the first chapter, before describing the actual patterns. This is very helpful since it lays the foundation for the following chapters.The author also warns us that adopting certain patterns (e.g. <em><strong>Observer<\/strong><\/em>) might sometimes result in <em><strong>overengineering<\/strong><\/em>. I couldn&#8217;t agree more! One has to understand the various design patterns and apply them judiciously while implementing real-world projects.<\/p>\n<p>All the patterns described in the <em><strong>GoF<\/strong><\/em> are covered in this book as well, and more or less, in the same order.<span class=\"Apple-converted-space\">\u00a0<\/span><\/p>\n<h3><strong>1. Creational Patterns:<\/strong><\/h3>\n<p style=\"padding-left: 30px;\">&#8211; Builder<\/p>\n<p style=\"padding-left: 30px;\">&#8211; Factories (Abstract factory and Factory Method)<\/p>\n<p style=\"padding-left: 30px;\">&#8211; Prototype<\/p>\n<p style=\"padding-left: 30px;\">&#8211; Singleton<\/p>\n<h3><strong>2. Structural Patterns:<\/strong><\/h3>\n<p style=\"padding-left: 30px;\">&#8211; Adapter<\/p>\n<p style=\"padding-left: 30px;\">&#8211; Bridge<\/p>\n<p style=\"padding-left: 30px;\">&#8211; Composite<\/p>\n<p style=\"padding-left: 30px;\">&#8211; Decorator<\/p>\n<p style=\"padding-left: 30px;\">&#8211; Facade<\/p>\n<p style=\"padding-left: 30px;\">&#8211; Flyweight<\/p>\n<p style=\"padding-left: 30px;\">&#8211; Proxy<\/p>\n<h3><strong>3. Behavioral Patterns:<\/strong><\/h3>\n<p style=\"padding-left: 30px;\">&#8211; Chain of Responsibility<\/p>\n<p style=\"padding-left: 30px;\">&#8211; Command<\/p>\n<p style=\"padding-left: 30px;\">&#8211; Interpreter<\/p>\n<p style=\"padding-left: 30px;\">&#8211; Iterator<\/p>\n<p style=\"padding-left: 30px;\">&#8211; Mediator<\/p>\n<p style=\"padding-left: 30px;\">&#8211; Memento<\/p>\n<p style=\"padding-left: 30px;\">&#8211; Null Object<span class=\"Apple-converted-space\">\u00a0<\/span><\/p>\n<p style=\"padding-left: 30px;\">&#8211; Observer<\/p>\n<p style=\"padding-left: 30px;\">&#8211; State<\/p>\n<p style=\"padding-left: 30px;\">&#8211; Strategy<\/p>\n<p style=\"padding-left: 30px;\">&#8211; Template Method<\/p>\n<p style=\"padding-left: 30px;\">&#8211; Visitor<\/p>\n<p>The <em><strong>Null Object<\/strong><\/em> pattern under <em><strong>Behaviour Patterns<\/strong><\/em> was not described in the <em><strong>GoF<\/strong><\/em> book, but subsequently appeared in <a href=\"https:\/\/books.google.co.in\/books\/about\/Pattern_languages_of_program_design_3.html?id=r6ZQAAAAMAAJ&amp;redir_esc=y\" target=\"_blank\" rel=\"noopener\"><em><strong>Pattern Languages of Program Design, Volume 3<\/strong><\/em><\/a>.<span class=\"Apple-converted-space\">\u00a0<\/span><\/p>\n<p>A nice bonus is the discussion on <em><strong>Maybe Monad<\/strong><\/em> in the Appendix. <a href=\"http:\/\/learnyouahaskell.com\/a-fistful-of-monads\" target=\"_blank\" rel=\"noopener\"><em><strong>Monads<\/strong><\/em><\/a> are originally from Haskell and there are libraries attempting to support them in other languages such as <em><strong>Python<\/strong><\/em>, <em><strong>Ruby<\/strong><\/em> and <em><strong>Lisp<\/strong><\/em>. It is interesting to learn about it from C++ point of view.<span class=\"Apple-converted-space\">\u00a0<\/span><\/p>\n<p>I must say I thoroughly enjoyed reading this book and I recommend it highly. If you are a serious C++ developer, just go and buy it!<\/p>\n<p>I found two interesting sites that discuss C++ <em><strong>Design Patterns<\/strong><\/em>. See <a href=\"https:\/\/cpppatterns.com\" target=\"_blank\" rel=\"noopener\"><em><strong>this<\/strong><\/em><\/a>\u00a0and <a href=\"https:\/\/github.com\/JakubVojvoda\/design-patterns-cpp\" target=\"_blank\" rel=\"noopener\"><em><strong>this<\/strong><\/em><\/a>.<\/p>\n<p>(P.S. I am also reading a couple of other good books on <em><strong>C++ Concurrency<\/strong><\/em> and <em><strong>Designing DSLs<\/strong><\/em>. So don\u2019t be surprised if I continue with book reviews in the next few posts as well!)<\/p>\n<p>Have a great weekend!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Title: Design Patterns in Modern C++ &#8211; Reusable Approaches for Object-Oriented Software Design Author: Dmitri Nesteruk Publisher: Apress Year: 2018 Luck has been on my side for the past few weeks; I have been getting access to nice books to read. I wrote about The\u00a0Modern C++ Challenge in my last post. Today, I am going [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[94,49],"tags":[67,146],"class_list":["post-988","post","type-post","status-publish","format-standard","hentry","category-book-review","category-c","tag-c","tag-design-patterns"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9OLnF-fW","jetpack-related-posts":[{"id":2868,"url":"https:\/\/www.rangakrish.com\/index.php\/2022\/07\/11\/book-review-beautiful-c-30-core-guidelines-for-writing-clean-safe-and-fast-code\/","url_meta":{"origin":988,"position":0},"title":"Book Review &#8211;  Beautiful C++: 30 Core Guidelines for Writing Clean, Safe, and Fast Code","author":"admin","date":"July 11, 2022","format":false,"excerpt":"Title: Beautiful C++: 30 Core Guidelines for Writing Clean, Safe, and Fast Code Authors: J.Guy Davidson, Kate Gregory Publisher:\u00a0 Pearson Education Year: 2022 My earliest introduction to C++ guidelines was through Scott Meyers\u2019 excellent book Effective C++ that first appeared in 1992. After programming in C++ for around 3 years\u2026","rel":"","context":"In &quot;Book Review&quot;","block_context":{"text":"Book Review","link":"https:\/\/www.rangakrish.com\/index.php\/category\/book-review\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/07\/Book-Cover2-233x300.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1496,"url":"https:\/\/www.rangakrish.com\/index.php\/2019\/03\/10\/book-review-c-concurrency-in-action\/","url_meta":{"origin":988,"position":1},"title":"Book Review: C++ Concurrency in Action","author":"admin","date":"March 10, 2019","format":false,"excerpt":"Title: C++ Concurrency in Action Author: Anthony Williams Publisher: Manning Publications Co. Year: 2019 (Second Edition) \u00a0 The first edition of this book came out in the year 2012 and covered the concurrency features of C++ 11. Much has happened since then. The present C++17 is significantly richer in terms\u2026","rel":"","context":"In &quot;Book Review&quot;","block_context":{"text":"Book Review","link":"https:\/\/www.rangakrish.com\/index.php\/category\/book-review\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2915,"url":"https:\/\/www.rangakrish.com\/index.php\/2022\/09\/18\/book-review-embracing-modern-c-safely\/","url_meta":{"origin":988,"position":2},"title":"Book Review: Embracing Modern C++ Safely","author":"admin","date":"September 18, 2022","format":false,"excerpt":"Title: Embracing Modern C++ Safely Authors: John Laos, Vittorio Romeo, Rostislav Khlebnikov, and Alisdair Meredith Publisher: Pearson Education, Inc. Year: 2022 C++ is a complex language. Fortunately, we have several good books (and other online material) for programmers at various levels. A few weeks ago, I had reviewed and recommended\u2026","rel":"","context":"In &quot;Book Review&quot;","block_context":{"text":"Book Review","link":"https:\/\/www.rangakrish.com\/index.php\/category\/book-review\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/09\/Book2-235x300.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":980,"url":"https:\/\/www.rangakrish.com\/index.php\/2018\/07\/08\/book-review-the-modern-c-challenge\/","url_meta":{"origin":988,"position":3},"title":"Book Review &#8211; The Modern C++ Challenge","author":"admin","date":"July 8, 2018","format":false,"excerpt":"Title: The Modern C++ Challenge Author: Marius Bancilla Publisher: Packt Publishing Year: May 2018\u00a0 This week I have been going through a new book titled The Modern C++ Challenge written by Marius Bancilla. The book is a collection of programming problems (along with suggested solutions) targeting C++ . The title\u2026","rel":"","context":"In &quot;Book Review&quot;","block_context":{"text":"Book Review","link":"https:\/\/www.rangakrish.com\/index.php\/category\/book-review\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1339,"url":"https:\/\/www.rangakrish.com\/index.php\/2018\/12\/23\/book-review-real-time-c\/","url_meta":{"origin":988,"position":4},"title":"Book Review: Real-Time C++","author":"admin","date":"December 23, 2018","format":false,"excerpt":"Title: Real-Time C++: Efficient Object-Oriented and Template Microcontroller Programming Author: Christopher Kormanyos Publisher: Springer-Verlag Year: 2018 (Third Edition) It was the title of this book which caught my attention a few weeks ago and I decided to invest in it. I am not in to real-time software development these days,\u2026","rel":"","context":"In &quot;Book Review&quot;","block_context":{"text":"Book Review","link":"https:\/\/www.rangakrish.com\/index.php\/category\/book-review\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2986,"url":"https:\/\/www.rangakrish.com\/index.php\/2023\/01\/11\/book-review-adventures-in-rule-based-programming-a-clips-tutorial\/","url_meta":{"origin":988,"position":5},"title":"Book Review: Adventures in Rule-Based Programming &#8211; A CLIPS Tutorial","author":"admin","date":"January 11, 2023","format":false,"excerpt":"Title: Adventures in Rule-Based Programming - A CLIPS Tutorial Author: Gary Riley Publisher: Secret Society Software, LLC Year: 2022 In an earlier article, I had talked about the relevance of Rule-based systems today. In that article I had also listed a few Rule engines that are popular and widely used.\u2026","rel":"","context":"In &quot;Knowledge Representation&quot;","block_context":{"text":"Knowledge Representation","link":"https:\/\/www.rangakrish.com\/index.php\/category\/knowledge-representation\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/01\/Cover-188x300.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/988","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/comments?post=988"}],"version-history":[{"count":0,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/988\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/media?parent=988"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/categories?post=988"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/tags?post=988"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}