{"id":17224,"date":"2017-05-26T12:15:53","date_gmt":"2017-05-26T09:15:53","guid":{"rendered":"https:\/\/www.webcodegeeks.com\/?p=17224"},"modified":"2017-05-26T10:53:35","modified_gmt":"2017-05-26T07:53:35","slug":"refactoring-design-patterns","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/","title":{"rendered":"Refactoring and Design Patterns"},"content":{"rendered":"<p>Refactoring is a simple concept, and yet it takes some learning to come to a point where refactoring is beneficial. Refactoring means making small adjustments to code throughout the life of a system in order to improve many aspects and give better long-term results.<\/p>\n<h2>Why Refactor Your Code?<\/h2>\n<p>The purpose for refactoring code can be for readability, creating a more modular design for ease of upgrading or extending, performance improvements, or things like experimentation with new methodologies and technologies. Refactoring code does not change behavior or output. It is only a reworking of the implementation details.<\/p>\n<p>In programming, there is a practice called <strong>Red, Green, Refactor<\/strong>, which is a practice of Test Driven Development.<\/p>\n<p>The purpose of the <strong>red<\/strong> phase is to define an aspect of the code you want to implement and prove that the test is being executed via its failure message. If you skip this step, you may end up with a test that doesn\u2019t get run when all your \u201cother\u201d tests show up as green <em>(dead code)<\/em>.<\/p>\n<p>The <strong>green<\/strong> step is rather simple: it\u2019s when you write the code to make that test pass.<\/p>\n<p>The <strong>refactor<\/strong> step is a very valuable step in which you apply your learned knowledge of good code practices and make small adjustments without changing the codes behavior.<\/p>\n<p>Code that doesn\u2019t get refactored as a system evolves is the common culprit for technical debt. Technical debt is a term used for the increasing amount of work that should be done to make a system more manageable. Without having a good understanding of many design patterns and the simple discipline of small refactoring as you go along, you can end up with quite a kludge of code that needs to be \u201cfixed.\u201d<\/p>\n<h2>Initial Setbacks<\/h2>\n<p>When a person starts learning how to program, they start learning a process of how to think through problems. They get an initial understanding of setting state, evaluating it, and conditional behavior. This may seem good for learning a language but none of the good coding practices are instilled in them at this stage. This level of knowledge will likely lead to high code coupling and deeply nested conditionals that get harder to wrap your head around or maintain.<\/p>\n<p>There are design patterns that help decouple and remove most of the heavy query method usage, such as Tell Don\u2019t Ask, Eastward Oriented Code, and Monads. Learning to apply patterns such as these will help relieve you of many of the headaches you experienced as a new programmer.<\/p>\n<p>When a person has spent a lot of time with writing heavily coupled code and changing state across objects, it takes a bit of effort to change and think as one should about writing better code.<\/p>\n<p>This is further evident when it comes to writing threaded programs. When a program can have several things try to access or change the same item, you end up with problems. Mutating state with coupling or threading is the source of many issues.<\/p>\n<h2>The Benefit of Decoupling<\/h2>\n<p>Coupling in programming is when objects know specific things about how to call and use other objects.<\/p>\n<p>For an example of high coupling, imagine a method call like <code>user.profile.address.phone<\/code> and then imagine the program gets changed so that <code>phone<\/code> will now be a method call on a <code>communication<\/code> object on <code>profile<\/code> instead of <code>address<\/code>. If you\u2019re calling methods like this, there is a high chance that this deeply nested call is written many times over your code base. The change to using the <code>communication<\/code> object will require hundreds of changes throughout that code base.<\/p>\n<p>To help decouple, it\u2019s better to move toward one method call on any one object when possible. So in the above example, we can write a method on <code>user<\/code> called <code>phone<\/code>, which calls <code>profile.phone<\/code>. <code>profile<\/code> will likewise call <code>address.phone<\/code> where <code>address<\/code> gets the <code>phone<\/code> object back. So now to call the method, you simply use <code>user.phone<\/code>. To make the change, you only need to change the code in one place: change <code>profile.phone<\/code> to call <code>communication.phone<\/code> instead of <code>address.phone<\/code> and every place in the program that calls <code>user.phone<\/code> will just work without needing to be updated.<\/p>\n<p>So now the benefit of decoupling is becoming quite clear. It allows you to maintain large code bases, making change easier to manage.<\/p>\n<p>Decoupling is important when integrating external dependencies. It may seem counterintuitive at first, but \u201ccreating more objects\u201d to act as middle man is a great way to decouple code for easier changes.<\/p>\n<p>Instead of calling the API\/methods of external dependencies directly from various places in your code base, you define your own wrapper object(s) which will have each method call mapped to the appropriate method on your external dependency. This way you can swap your external dependencies one for another as easily as writing another wrapper object with the same methods on it.<\/p>\n<h2>Refactoring in Rails<\/h2>\n<p>You may have heard stories, or you\u2019ve experienced them, where the <code>User<\/code> model ends up with a massive amount of code in it and the views have overly complex rendering logic in them. These \u201ccode smells\u201d are a good hint that some refactoring may be in order.<\/p>\n<p>By design, Rails has a way to organize data and behavior into specific areas to help maintanability and functionality. There are also additional design patterns you may implement along with with their standards. In the above scenario, the code may be implemented something like:<\/p>\n<ul>\n<li><strong>User Model<\/strong> \u2013 data store, organize data for presentation<\/li>\n<li><strong>Controller<\/strong> \u2013 selecting data for presentation and rendering the view<\/li>\n<li><strong>View<\/strong> \u2013 the layout with lots of conditional logic based on the user data<\/li>\n<\/ul>\n<p>Here, the view and the user model are both doing more than they should; they are not following the <em>single responsibility principle<\/em>. The user model shouldn\u2019t be responsible for organizing the data for presentation, and the view shouldn\u2019t contain too much conditional logic for how it\u2019s rendered. These should be separated out into different objects. A better organization of your code would look like:<\/p>\n<ul>\n<li><strong>User Model<\/strong> \u2013 data store<\/li>\n<li><strong>Controller<\/strong> \u2013 selecting data and wrap in presenter and render view<\/li>\n<li><strong>Presenter<\/strong> \u2013 organize model data for presentation (no HTML)<\/li>\n<li><strong>Helper<\/strong> \u2013 any conditional view logic that will be reused (HTML allowed)<\/li>\n<li><strong>View<\/strong> \u2013 the layout with simple method calls directly on presenter objects and any helpers (conditional logic should be mostly moved out to either the presenter or helper)<\/li>\n<\/ul>\n<p>Everything has been simplified towards <em>single responsibility<\/em>, and all the code should be much easier to read. Models will be smaller, and you don\u2019t have to guess what the view is doing.<\/p>\n<p>In the controller, it may be wise to employ the <em>Null Object Pattern<\/em> for a <code>UserPresenter<\/code>, where you create a <code>Guest<\/code> object that has all of the same methods as the <code>User<\/code> model and you can call your presenter with something like <code>UserPresenter.new(current_user || Guest.new)<\/code>. This way if no one is logged in to your site, the view can still call the same methods for your user and get the appropriate results for a guest.<\/p>\n<h2>Learning Resources<\/h2>\n<p>There are many resources available to learn about refactoring and design patterns. Here are some excellent resources, many of which I enjoy revisiting to better reinforce my understanding of good practices and design. Many practices are best learned through demonstration, so I highly recommend a look at these.<\/p>\n<ul>\n<li>Presenter Pattern (Blog Post) \u2014 <a href=\"http:\/\/nithinbekal.com\/posts\/rails-presenters\/\">Presenters in Rails<\/a> by Nithin Bekal<\/li>\n<li>Red, Green, Refactor (Video) \u2014 <a href=\"https:\/\/www.youtube.com\/watch?v=983zk0eqYLY\">Roman Numerals Kata<\/a> by Jim Weirich<\/li>\n<li>Refactoring (Video) \u2014 <a href=\"https:\/\/www.youtube.com\/watch?v=DC-pQPq0acs\">Refactoring from Good to Great<\/a> by Ben Orenstein<\/li>\n<li>Design Patterns (Book) \u2014 <a href=\"http:\/\/designpatternsinruby.com\/\">Design Patterns in Ruby<\/a> by Russ Olsen<\/li>\n<li>Refactoring by Example (Book) \u2014 <a href=\"https:\/\/www.sandimetz.com\/99bottles\">99 Bottles of OOP<\/a> by Sandi Metz<\/li>\n<li>Refactoring Tips (Email Newsletter) \u2014 <a href=\"https:\/\/www.getdrip.com\/forms\/21894477\/submissions\/new\">Refactoring Tips<\/a> by Avdi Grimm<\/li>\n<li>Eastward Oriented Code (Video) \u2014 <a href=\"https:\/\/www.youtube.com\/watch?v=kXcrClJcfm8\">Eastward Ho! A Clear Path Through Ruby With OO<\/a> by Jim Gay<\/li>\n<li>Monads (Video) \u2014 <a href=\"https:\/\/www.youtube.com\/watch?v=J1jYlPtkrqQ\">Refactoring Ruby with Monads<\/a> by Tom Stuart<\/li>\n<\/ul>\n<h2>Summary<\/h2>\n<p>When it comes to refactoring code for easier understanding and maintenance, it\u2019s often done by creating extra simple representational objects to abstract away complexity.<\/p>\n<p>Smaller amounts of refactoring can be done by following something like a <a href=\"https:\/\/github.com\/bbatsov\/ruby-style-guide\">style guide<\/a> with something as simple as swapping out a <a href=\"https:\/\/github.com\/bbatsov\/ruby-style-guide#no-nested-conditionals\">nested conditional for guard clauses<\/a>. What that does for you is to keep the code from having overly nested indentation toward the right, but rather to have the organization of code more aligned for easier comprehension and a little bit of elegance.<\/p>\n<p>Refactoring is a must for any programmer who wants to be worth their salt. It\u2019s understandable if you haven\u2019t been in the practice of doing it up to now. But once you know better, it\u2019s your responsibility, both to yourself and to others, to better educate yourself in this discipline and to live by it. You should strive to write code in a way that future changes will not be met with great difficulty. So like any athlete, take some time to train yourself and hone your skill. The world thanks you in advance.<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td><span class=\"reference\">Reference: <\/span><\/td>\n<td><a href=\"https:\/\/blog.codeship.com\/refactoring-and-design-patterns\/\">Refactoring and Design Patterns<\/a> from our <a href=\"http:\/\/www.webcodegeeks.com\/join-us\/wcg\/\">WCG partner<\/a>\u00a0Daniel P. Clark at the <a href=\"http:\/\/blog.codeship.com\/\">Codeship Blog<\/a> blog.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Refactoring is a simple concept, and yet it takes some learning to come to a point where refactoring is beneficial. Refactoring means making small adjustments to code throughout the life of a system in order to improve many aspects and give better long-term results. Why Refactor Your Code? The purpose for refactoring code can be &hellip;<\/p>\n","protected":false},"author":146,"featured_media":4127,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[95,467],"class_list":["post-17224","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-development","tag-rails","tag-refactoring"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Refactoring and Design Patterns - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Refactoring is a simple concept, and yet it takes some learning to come to a point where refactoring is beneficial. Refactoring means making small\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Refactoring and Design Patterns - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Refactoring is a simple concept, and yet it takes some learning to come to a point where refactoring is beneficial. Refactoring means making small\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2017-05-26T09:15:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Daniel P. Clark\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Daniel P. Clark\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/\"},\"author\":{\"name\":\"Daniel P. Clark\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/a79c83c57cba5d8a6e46462149890b5e\"},\"headline\":\"Refactoring and Design Patterns\",\"datePublished\":\"2017-05-26T09:15:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/\"},\"wordCount\":1491,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg\",\"keywords\":[\"Rails\",\"Refactoring\"],\"articleSection\":[\"Web Dev\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/\",\"name\":\"Refactoring and Design Patterns - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg\",\"datePublished\":\"2017-05-26T09:15:53+00:00\",\"description\":\"Refactoring is a simple concept, and yet it takes some learning to come to a point where refactoring is beneficial. Refactoring means making small\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Web Dev\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/web-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Refactoring and Design Patterns\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/a79c83c57cba5d8a6e46462149890b5e\",\"name\":\"Daniel P. Clark\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2342ad14824a1064823dcec81641a12136a3492abae522e473ec723cbfb84bce?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/2342ad14824a1064823dcec81641a12136a3492abae522e473ec723cbfb84bce?s=96&d=mm&r=g\",\"caption\":\"Daniel P. Clark\"},\"description\":\"Daniel P. Clark is a freelance developer, as well as a Ruby and Rust enthusiast. He writes about Ruby on his personal site.\",\"url\":\"https:\/\/www.webcodegeeks.com\/author\/daniel-clark\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Refactoring and Design Patterns - Web Code Geeks - 2026","description":"Refactoring is a simple concept, and yet it takes some learning to come to a point where refactoring is beneficial. Refactoring means making small","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/","og_locale":"en_US","og_type":"article","og_title":"Refactoring and Design Patterns - Web Code Geeks - 2026","og_description":"Refactoring is a simple concept, and yet it takes some learning to come to a point where refactoring is beneficial. Refactoring means making small","og_url":"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2017-05-26T09:15:53+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg","type":"image\/jpeg"}],"author":"Daniel P. Clark","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Daniel P. Clark","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/"},"author":{"name":"Daniel P. Clark","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/a79c83c57cba5d8a6e46462149890b5e"},"headline":"Refactoring and Design Patterns","datePublished":"2017-05-26T09:15:53+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/"},"wordCount":1491,"commentCount":1,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg","keywords":["Rails","Refactoring"],"articleSection":["Web Dev"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/","url":"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/","name":"Refactoring and Design Patterns - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg","datePublished":"2017-05-26T09:15:53+00:00","description":"Refactoring is a simple concept, and yet it takes some learning to come to a point where refactoring is beneficial. Refactoring means making small","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/web-development\/refactoring-design-patterns\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Web Dev","item":"https:\/\/www.webcodegeeks.com\/category\/web-development\/"},{"@type":"ListItem","position":3,"name":"Refactoring and Design Patterns"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/a79c83c57cba5d8a6e46462149890b5e","name":"Daniel P. Clark","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/2342ad14824a1064823dcec81641a12136a3492abae522e473ec723cbfb84bce?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2342ad14824a1064823dcec81641a12136a3492abae522e473ec723cbfb84bce?s=96&d=mm&r=g","caption":"Daniel P. Clark"},"description":"Daniel P. Clark is a freelance developer, as well as a Ruby and Rust enthusiast. He writes about Ruby on his personal site.","url":"https:\/\/www.webcodegeeks.com\/author\/daniel-clark\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/17224","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/146"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=17224"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/17224\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/4127"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=17224"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=17224"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=17224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}