{"id":6423,"date":"2022-08-15T20:05:04","date_gmt":"2022-08-15T20:05:04","guid":{"rendered":"https:\/\/www.modernescpp.com\/index.php\/the-structure-of-patterns\/"},"modified":"2022-08-15T20:05:04","modified_gmt":"2022-08-15T20:05:04","slug":"the-structure-of-patterns","status":"publish","type":"post","link":"https:\/\/www.modernescpp.com\/index.php\/the-structure-of-patterns\/","title":{"rendered":"The Structure of Patterns"},"content":{"rendered":"<p>The classics &#8220;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Design_Patterns\">Design Patterns: Elements of Reusable Object-Oriented Software&#8221;<\/a>, and <a href=\"https:\/\/en.wikipedia.org\/wiki\/Pattern-Oriented_Software_Architecture\">&#8220;<span id=\"productTitle\" class=\"a-size-extra-large\">Pattern-Oriented Software Architecture, Volume 1<\/span><\/a>&#8221; use similar steps to present their pattern. Today, I will present this structure of a pattern.<\/p>\n<p><!--more--><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-6421\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/patternsStructure.png\" alt=\"patternsStructure\" width=\"650\" height=\"329\" style=\"display: block; margin-left: auto; margin-right: auto;\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/patternsStructure.png 1216w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/patternsStructure-300x152.png 300w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/patternsStructure-1024x518.png 1024w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/patternsStructure-768x388.png 768w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/p>\n<p>Before I write about the structure of a pattern, let me bring you on the same page and start with the definition of a pattern according to Christopher Alexander.<\/p>\n<ul>\n<li><strong>Patttern<\/strong>: &#8220;<em>Each pattern is a three part rule, which expresses a relation between a certain context, a problem, and a solution.<\/em>&#8220;<\/li>\n<\/ul>\n<p>This means that a pattern describes a generic solution to a design problem that recurs in a particular context.<\/p>\n<ul>\n<li>The <strong>context<\/strong> is the design situation.<\/li>\n<li>The <strong>problem<\/strong> are the forces acting in this context.<\/li>\n<li>The <strong>solution<\/strong> is a configuration to balance the forces.<\/li>\n<\/ul>\n<p>Christopher Alexander uses the three adjectives useful, usable and used to describe the benefits of patterns.<\/p>\n<ul>\n<li><strong>Useful<\/strong>: A pattern needs to be useful.<\/li>\n<li><strong>Usable<\/strong>: A pattern needs to be implementable.<\/li>\n<li><strong>Used<\/strong>: Patterns are discovered, but not invented. This rule is called the rule of three:&nbsp; &#8220;<em>A pattern can be called a pattern only if it has been applied to a real world solution at least three times<\/em>.&#8221; (<a href=\"https:\/\/wiki.c2.com\/?RuleOfThree\">https:\/\/wiki.c2.com\/?RuleOfThree<\/a>)<\/li>\n<\/ul>\n<p>Now, let me write about the structure of a pattern.<\/p>\n<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Structure_of_a_Pattern\"><\/span>Structure of a Pattern<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Honestly, there is a strange phenomenon. On the one hand, both books &#8220;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Design_Patterns\">Design Patterns: Elements of Reusable Object-Oriented Software&#8221;<\/a> and <a href=\"https:\/\/en.wikipedia.org\/wiki\/Pattern-Oriented_Software_Architecture\">&#8220;<span id=\"productTitle\" class=\"a-size-extra-large\">Pattern-Oriented Software Architecture, Volume 1<\/span><\/a>&#8221;&nbsp; are the most influential books ever written about software development. On the other hand, both books have a great fall-asleep factor. This fall asleep factor is mainly due to the fact that both books present their patterns in&nbsp;monotonously repeating 13 steps.<\/p>\n<p>In order to bore you not to death, I present these 13 steps concisely by applying the &#8220;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Design_Patterns\">Design Patterns: Elements of Reusable Object-Oriented Software&#8221;<\/a>&nbsp; structure to the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Strategy_pattern\">strategy pattern<\/a>. The intention of each step is displayed in italic. The non-italic contents refer to the strategy pattern.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Name\"><\/span>Name<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><em>A concise name that is easy to remember.<\/em><\/p>\n<p>Strategy pattern<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Intent\"><\/span>Intent<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><em>An answer to the question: What is the purpose of the pattern?<\/em><\/p>\n<p>Define a family of algorithms, encapsulate them in objects, and make them interchangeable at the run time of your program.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Also_known_as\"><\/span>Also known as<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><em>Alternative names for the pattern if known.<\/em><\/p>\n<p>Policy<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Motivation\"><\/span>Motivation<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><em>A motivational example for the pattern.<\/em><\/p>\n<p>A container of strings can be sorted in various ways. You can sort them lexicographically, case-insensitive, reverse, based on the length of the string, based on the first n characters &#8230; . Hard coding your sorting criteria into your sorting algorithm would be a maintenance nightmare. Consequentially, you make your sorting criteria an object that encapsulates the sorting criteria and configures your sorting algorithm with it.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Applicability\"><\/span>Applicability<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><em>Situations in which you can apply the pattern.<\/em><\/p>\n<p>The strategy pattern is applicable when<\/p>\n<ul>\n<li>many related classes differ only in their behavior.<\/li>\n<li>you need different variants of an algorithm.<\/li>\n<li>the algorithms should be transparent to the client.<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"Structure\"><\/span>Structure<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><em>A graphical representation of the pattern.<\/em><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-6422\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/Strategy.png\" alt=\"Strategy\" width=\"332\" height=\"215\" style=\"display: block; margin-left: auto; margin-right: auto;\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/Strategy.png 332w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/Strategy-300x194.png 300w\" sizes=\"auto, (max-width: 332px) 100vw, 332px\" \/><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Participants\"><\/span>Participants<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><em>Classes and objects that participate in this pattern<\/em>.<\/p>\n<ul>\n<li><code><strong>Context<\/strong><\/code>: uses a concrete strategy, implementing the <code>Strategy<\/code> interface<\/li>\n<li><code><strong>Strategy<\/strong><\/code>: declares the interface for the various strategies<\/li>\n<li><code><strong>ConcreteStrategyA<\/strong>, <strong>ConcreteStrategyB<\/strong><\/code>: implements the strategy<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"Collaboration\"><\/span>Collaboration<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><em>Collaboration with the participants.<\/em><\/p>\n<p>The context and the concrete strategy implement the chosen algorithm. The context forward client request to the used concrete strategy.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Consequences\"><\/span>Consequences<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><em>What are the pros and cons of the pattern?<\/em><\/p>\n<p>The benefits of the strategy pattern are:<\/p>\n<ul>\n<li>Families of related algorithms can be used uniformly.<\/li>\n<li>The client is hidden from implementation details.<\/li>\n<li>The algorithms can be exchanged during run time.<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"Implementation\"><\/span>Implementation<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><em>Implementation techniques of the pattern.<\/em><\/p>\n<ol>\n<li>Define the context and the Strategy interface.<\/li>\n<li>Implement concrete strategies.<\/li>\n<li>The context can take its arguments at run time or at compile time as a template parameter.<\/li>\n<\/ol>\n<h3><span class=\"ez-toc-section\" id=\"Sample_Code\"><\/span>Sample Code<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><em>Code snippets illustrating the implementation of the pattern. This book uses Smalltalk and C++.<\/em><\/p>\n<p>The strategy pattern is so baked in the design of the Standard Template Library that we may not see it. Additionally, the STL often uses lightweight variants of the strategy pattern.<\/p>\n<p>Here are two of many examples:<\/p>\n<h4>STL Algorithms<\/h4>\n<p><code>std::sort<\/code> can be parametrized with a sorting criterion. The sorting criteria must be a binary predicate. Lambdas are perfect fits for such binary predicates:<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #f0f3f3; overflow: auto; width: auto; gray;border-width: .1em .1em .1em .8em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #0099ff; font-style: italic;\">\/\/ strategySorting.cpp<\/span>\r\n\r\n<span style=\"color: #009999;\">#include &lt;algorithm&gt;<\/span>\r\n<span style=\"color: #009999;\">#include &lt;functional&gt;<\/span>\r\n<span style=\"color: #009999;\">#include &lt;iostream&gt;<\/span>\r\n<span style=\"color: #009999;\">#include &lt;string&gt;<\/span>\r\n<span style=\"color: #009999;\">#include &lt;vector&gt;<\/span>\r\n\r\n<span style=\"color: #007788; font-weight: bold;\">void<\/span> <span style=\"color: #cc00ff;\">showMe<\/span>(<span style=\"color: #006699; font-weight: bold;\">const<\/span> std<span style=\"color: #555555;\">::<\/span>vector<span style=\"color: #555555;\">&lt;<\/span>std<span style=\"color: #555555;\">::<\/span>string<span style=\"color: #555555;\">&gt;&amp;<\/span> myVec) {\r\n    <span style=\"color: #006699; font-weight: bold;\">for<\/span> (<span style=\"color: #006699; font-weight: bold;\">const<\/span> <span style=\"color: #006699; font-weight: bold;\">auto<\/span><span style=\"color: #555555;\">&amp;<\/span> v<span style=\"color: #555555;\">:<\/span> myVec) std<span style=\"color: #555555;\">::<\/span>cout <span style=\"color: #555555;\">&lt;&lt;<\/span> v <span style=\"color: #555555;\">&lt;&lt;<\/span> <span style=\"color: #cc3300;\">\" \"<\/span>;\r\n    std<span style=\"color: #555555;\">::<\/span>cout <span style=\"color: #555555;\">&lt;&lt;<\/span> <span style=\"color: #cc3300;\">\"<\/span><span style=\"color: #cc3300; font-weight: bold;\">\\n\\n<\/span><span style=\"color: #cc3300;\">\"<\/span>;\r\n}\r\n\r\n\r\n<span style=\"color: #007788; font-weight: bold;\">int<\/span> <span style=\"color: #cc00ff;\">main<\/span>(){\r\n\r\n    std<span style=\"color: #555555;\">::<\/span>cout <span style=\"color: #555555;\">&lt;&lt;<\/span> <span style=\"color: #cc3300;\">'\\n'<\/span>;\r\n\r\n    <span style=\"color: #0099ff; font-style: italic;\">\/\/ initializing with a initializer lists<\/span>\r\n    std<span style=\"color: #555555;\">::<\/span>vector<span style=\"color: #555555;\">&lt;<\/span>std<span style=\"color: #555555;\">::<\/span>string<span style=\"color: #555555;\">&gt;<\/span> myStrVec <span style=\"color: #555555;\">=<\/span> {<span style=\"color: #cc3300;\">\"Only\"<\/span>, <span style=\"color: #cc3300;\">\"for\"<\/span>, <span style=\"color: #cc3300;\">\"Testing\"<\/span>, <span style=\"color: #cc3300;\">\"Purpose\"<\/span>, <span style=\"color: #cc3300;\">\"!!!!!\"<\/span>};\r\n    showMe(myStrVec);     <span style=\"color: #0099ff; font-style: italic;\">\/\/ Only for Testing Purpose !!!!! <\/span>\r\n\r\n    <span style=\"color: #0099ff; font-style: italic;\">\/\/ lexicographic sorting<\/span>\r\n    std<span style=\"color: #555555;\">::<\/span>sort(myStrVec.begin(), myStrVec.end());\r\n    showMe(myStrVec);    <span style=\"color: #0099ff; font-style: italic;\">\/\/ !!!!! Only Purpose Testing for <\/span>\r\n\r\n    <span style=\"color: #0099ff; font-style: italic;\">\/\/ case insensitive first character<\/span>\r\n    std<span style=\"color: #555555;\">::<\/span>sort(myStrVec.begin(), myStrVec.end(), \r\n              [](<span style=\"color: #006699; font-weight: bold;\">const<\/span> std<span style=\"color: #555555;\">::<\/span>string<span style=\"color: #555555;\">&amp;<\/span> f, <span style=\"color: #006699; font-weight: bold;\">const<\/span> std<span style=\"color: #555555;\">::<\/span>string<span style=\"color: #555555;\">&amp;<\/span> s){ <span style=\"color: #006699; font-weight: bold;\">return<\/span> std<span style=\"color: #555555;\">::<\/span>tolower(f[<span style=\"color: #ff6600;\">0<\/span>]) <span style=\"color: #555555;\">&lt;<\/span> std<span style=\"color: #555555;\">::<\/span>tolower(s[<span style=\"color: #ff6600;\">0<\/span>]); });\r\n    showMe(myStrVec);   <span style=\"color: #0099ff; font-style: italic;\">\/\/ !!!!! for Only Purpose Testing <\/span>\r\n\r\n    <span style=\"color: #0099ff; font-style: italic;\">\/\/ sorting ascending based on the length of the strings<\/span>\r\n    std<span style=\"color: #555555;\">::<\/span>sort(myStrVec.begin(), myStrVec.end(), \r\n              [](<span style=\"color: #006699; font-weight: bold;\">const<\/span> std<span style=\"color: #555555;\">::<\/span>string<span style=\"color: #555555;\">&amp;<\/span> f, <span style=\"color: #006699; font-weight: bold;\">const<\/span> std<span style=\"color: #555555;\">::<\/span>string<span style=\"color: #555555;\">&amp;<\/span> s){ <span style=\"color: #006699; font-weight: bold;\">return<\/span> f.length() <span style=\"color: #555555;\">&lt;<\/span> s.length(); });\r\n    showMe(myStrVec);   <span style=\"color: #0099ff; font-style: italic;\">\/\/ for Only !!!!! Purpose Testing <\/span>\r\n\r\n    <span style=\"color: #0099ff; font-style: italic;\">\/\/ reverse <\/span>\r\n    std<span style=\"color: #555555;\">::<\/span>sort(myStrVec.begin(), myStrVec.end(), std<span style=\"color: #555555;\">::<\/span>greater<span style=\"color: #555555;\">&lt;<\/span>std<span style=\"color: #555555;\">::<\/span>string<span style=\"color: #555555;\">&gt;<\/span>() );\r\n    showMe(myStrVec);   <span style=\"color: #0099ff; font-style: italic;\">\/\/ for Testing Purpose Only !!!!! <\/span>\r\n\r\n    std<span style=\"color: #555555;\">::<\/span>cout <span style=\"color: #555555;\">&lt;&lt;<\/span> <span style=\"color: #cc3300;\">\"<\/span><span style=\"color: #cc3300; font-weight: bold;\">\\n\\n<\/span><span style=\"color: #cc3300;\">\"<\/span>;\r\n\r\n}\r\n<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p>The program<code> strategySorting.cpp<\/code> sorts the vector lexicographically, case-insensitive, ascending based on the length of the strings, and in reverse order. For the reverse sorting, I use the predefined <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/utility\/functional\">function object<\/a> <code>std::greater. <\/code>The output of the program is directly displayed in the source code.<\/p>\n<h4>STL Containers<\/h4>\n<p>A policy is a generic function or class whose behavior can be configured. Typically, there are default values for the policy parameters. <code>std::vector<\/code> and<code> std::unordered_map<\/code> exemplifies these policies in C++. Of course, a policy is a strategy configured at compile time on template parameters.<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #f0f3f3; overflow: auto; width: auto; gray;border-width: .1em .1em .1em .8em;\">\n<pre style=\"margin: 0px; line-height: 125%;\"><span style=\"color: #006699; font-weight: bold;\">template<\/span><span style=\"color: #555555;\">&lt;<\/span><span style=\"color: #006699; font-weight: bold;\">class<\/span> <span style=\"color: #00aa88; font-weight: bold;\">T<\/span>, <span style=\"color: #006699; font-weight: bold;\">class<\/span> <span style=\"color: #00aa88; font-weight: bold;\">Allocator<\/span> <span style=\"color: #555555;\">=<\/span> std<span style=\"color: #555555;\">::<\/span>allocator<span style=\"color: #555555;\">&lt;<\/span>T<span style=\"color: #555555;\">&gt;&gt;<\/span>          <em><span style=\"color: #3366ff;\">\/\/ (1)<\/span><\/em>\r\n<span style=\"color: #006699; font-weight: bold;\">class<\/span> <span style=\"color: #00aa88; font-weight: bold;\">vector<\/span>; \r\n\r\n<span style=\"color: #006699; font-weight: bold;\">template<\/span><span style=\"color: #555555;\">&lt;<\/span><span style=\"color: #006699; font-weight: bold;\">class<\/span> <span style=\"color: #00aa88; font-weight: bold;\">Key<\/span>,\r\n    <span style=\"color: #006699; font-weight: bold;\">class<\/span> <span style=\"color: #00aa88; font-weight: bold;\">T<\/span>,\r\n    <span style=\"color: #006699; font-weight: bold;\">class<\/span> <span style=\"color: #00aa88; font-weight: bold;\">Hash<\/span> <span style=\"color: #555555;\">=<\/span> std<span style=\"color: #555555;\">::<\/span>hash<span style=\"color: #555555;\">&lt;<\/span>Key<span style=\"color: #555555;\">&gt;<\/span>,                              <em><span style=\"color: #3366ff;\"> \/\/ (3)<\/span><\/em>\r\n    <span style=\"color: #006699; font-weight: bold;\">class<\/span> <span style=\"color: #00aa88; font-weight: bold;\">KeyEqual<\/span> <span style=\"color: #555555;\">=<\/span> std<span style=\"color: #555555;\">::<\/span>equal_to<span style=\"color: #555555;\">&lt;<\/span>Key<span style=\"color: #555555;\">&gt;<\/span>,                      <em><span style=\"color: #3366ff;\"> \/\/ (4)<\/span><\/em>\r\n    <span style=\"color: #006699; font-weight: bold;\">class<\/span> <span style=\"color: #00aa88; font-weight: bold;\">allocator<\/span> <span style=\"color: #555555;\">=<\/span> std<span style=\"color: #555555;\">::<\/span>allocator<span style=\"color: #555555;\">&lt;<\/span>std<span style=\"color: #555555;\">::<\/span>pair<span style=\"color: #555555;\">&lt;<\/span><span style=\"color: #006699; font-weight: bold;\">const<\/span> Key, T<span style=\"color: #555555;\">&gt;&gt;<\/span>  <em><span style=\"color: #3366ff;\">\/\/ (2)<\/span><\/em>\r\n<span style=\"color: #006699; font-weight: bold;\">class<\/span> <span style=\"color: #00aa88; font-weight: bold;\">unordered_map<\/span>;\r\n<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p>This means each container has a default allocator for its elements, depending on<code> T<\/code> (line 1) or on <code>std::pair&lt;const Key, T&gt;<\/code> (line 2). Additionally,<code> std::unorderd_map<\/code> has a default hash function (line 3) and a default equal function (4). The hash function calculates the hash value based on the key, and the equal function deals with collisions in the buckets.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Known_uses\"><\/span>Known uses<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><em>At least two examples of known use of the pattern.<\/em><\/p>\n<p>There are way more use cases of strategies in modern C++.<\/p>\n<ul>\n<li>In C++17, you can configure about 70 of the STL algorithms with an execution policy. Here is one overload of <code>std::sort<\/code>:<\/li>\n<\/ul>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #f0f3f3; overflow: auto; width: auto; gray;border-width: .1em .1em .1em .8em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #006699; font-weight: bold;\">template<\/span><span style=\"color: #555555;\">&lt;<\/span> <span style=\"color: #006699; font-weight: bold;\">class<\/span> <span style=\"color: #00aa88; font-weight: bold;\">ExecutionPolicy<\/span>, <span style=\"color: #006699; font-weight: bold;\">class<\/span> <span style=\"color: #00aa88; font-weight: bold;\">RandomIt<\/span> <span style=\"color: #555555;\">&gt;<\/span>\r\n<span style=\"color: #007788; font-weight: bold;\">void<\/span> sort( ExecutionPolicy<span style=\"color: #555555;\">&amp;&amp;<\/span> policy,\r\n           RandomIt first, RandomIt last );\r\n<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p>Thanks to the execution policy, you can sort sequentially <code>(std::execution::seq<\/code>), parallel (<code>std::execution::par<\/code>), or parallel and vectorized (<code>std::execution::par_unseq<\/code>).<\/p>\n<ul>\n<li>In C++20, most of the classic STL algorithms have a ranges pendant. These ranges pendants support additional customization points such as projections. Read more about them in my previous post, &#8220;<a href=\"https:\/\/www.modernescpp.com\/index.php\/projections-with-ranges\">Projection with Ranges<\/a>&#8220;.<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"Related_Patterns\"><\/span>Related Patterns<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><em>Patterns that are closely related to this pattern.<\/em><\/p>\n<p>Strategy objects should be lightweight objects. Consequentially, lambda expressions are an ideal fit.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Whats_next\"><\/span>What&#8217;s next?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>You may wonder, what is the difference between a pattern, an algorithm, or a framework? Let me clarify this in my next post and introduce terms such as pattern sequences and pattern languages.<\/p>\n<p>&nbsp;<\/p>\n<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The classics &#8220;Design Patterns: Elements of Reusable Object-Oriented Software&#8221;, and &#8220;Pattern-Oriented Software Architecture, Volume 1&#8221; use similar steps to present their pattern. Today, I will present this structure of a pattern.<\/p>\n","protected":false},"author":21,"featured_media":6421,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[379],"tags":[],"class_list":["post-6423","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-patterns"],"_links":{"self":[{"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/posts\/6423","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/comments?post=6423"}],"version-history":[{"count":0,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/posts\/6423\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/media\/6421"}],"wp:attachment":[{"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/media?parent=6423"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/categories?post=6423"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/tags?post=6423"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}