{"id":104,"date":"2005-05-05T20:50:13","date_gmt":"2005-05-05T20:50:13","guid":{"rendered":"http:\/\/kubasek.com\/blog\/pragmatic_craftsman\/?p=104"},"modified":"2005-05-05T20:50:13","modified_gmt":"2005-05-05T20:50:13","slug":"learning-gof-design-patterns-and-refactoring","status":"publish","type":"post","link":"https:\/\/pragmaticcraftsman.kubasek.com\/2005\/05\/05\/learning-gof-design-patterns-and-refactoring\/","title":{"rendered":"Learning GoF Design Patterns and Refactoring"},"content":{"rendered":"<p>To learn design patterns is not easy. It&#8217;s one thing to just read about them and think you know them. It&#8217;s another thing to actually know how to use them, and to remember them as time passes by. I must admit, there is only a couple of the GoF patterns I remember. I read about them and after a while I forget them. However, that might be changing, as I have a different approach: I read several books on patterns at the same time.<\/p>\n<p>A while back, I read Robert Martin&#8217;s <a href=\"http:\/\/www.amazon.com\/exec\/obidos\/ASIN\/0135974445\/qid=1115338487\/sr=2-1\/ref=pd_bbs_b_2_1\/104-5439530-5210362\">Agile Software Development, Principles, Patterns, and Practices<\/a> (a great book). I also  read portions of the first edition of <a href=\"http:\/\/www.amazon.com\/exec\/obidos\/tg\/detail\/-\/0321247140\/qid=1115340058\/sr=8-1\/ref=pd_csp_1\/104-5439530-5210362?v=glance&amp;s=books&amp;n=507846\">Design Patterns Explained<\/a> (ok), portions of the classic <a href=\"http:\/\/www.amazon.com\/exec\/obidos\/tg\/detail\/-\/0201633612\/qid=1115338649\/sr=8-1\/ref=pd_csp_1\/104-5439530-5210362?v=glance&amp;s=books&amp;n=507846\">Design Patterns<\/a>, and the whole  <a href=\"http:\/\/www.amazon.com\/exec\/obidos\/tg\/detail\/-\/159059388X\/qid=1115338695\/sr=8-1\/ref=pd_csp_1\/104-5439530-5210362?v=glance&amp;s=books&amp;n=507846\">Holub on Patterns<\/a> (I did not like it at all). I own all of the books I mentioned (except Holub on Patterns). And I recently bought <a href=\"http:\/\/www.amazon.com\/exec\/obidos\/tg\/detail\/-\/0321213351\/qid=1115340058\/sr=8-2\/ref=pd_csp_2\/104-5439530-5210362?v=glance&amp;s=books&amp;n=507846\">Refactoring to Patterns<\/a> by Kerievski. This latest book is what prompted me to change how I study design patterns. (I also own Martin Fowler&#8217;s <a href=\"http:\/\/www.amazon.com\/exec\/obidos\/tg\/detail\/-\/0201485672\/qid=1115341356\/sr=8-1\/ref=pd_csp_1\/104-5439530-5210362?v=glance&amp;s=books&amp;n=507846\">Refactoring<\/a>, which is a classic book that every developer should have by his side.)<\/p>\n<p>I started reading Refactoring to Patterns. So far, about a third into the book, the book is very good. But I feel that the design patterns are starting to click. Why? As you might guess, the book tries to combine Fowler&#8217;s Refactoring and the GoF&#8217;s Design Patterns. So, whenever I read about a particular refactoring, I jump into Martin&#8217;s book. Not only that helps me understand the text better, I also get more info about the refactoring. (Plus, you get some good advice from Fowler, which I admire as a developer.) Same with patterns, whenever he mentions a GoF pattern (almost every refactoring), I go to the Design Patterns book.<\/p>\n<p>However, the GoF book is not easy, and the book by itself is not enough sometimes. That&#8217;s when I turn to Robert Martin&#8217;s book, which contains simple Java code for a lot of patterns he mentions. And because he doesn&#8217;t mention all of them, I hit the web. This site, <a href=\"http:\/\/www.dofactory.com\/Patterns\/Patterns.aspx\">Design Patterns<\/a>, contains code about all GoF patterns &#8212; very good resource.<\/p>\n<p>And if that was not enough, I try to write practice code in Eclipse. I created a <i>learn patterns<\/i> project, and I create a new package for each pattern. This is very useful when, down the road, you forget about the pattern and want a quick reminder (I learn by example). Design patterns are hard to learn because we don&#8217;t get to use them right away. By practicing them, you see them in real world. You see them from a different angle. This is very valuable.<\/p>\n<p>Have I found the ultimate solution for learning patterns. I don&#8217;t think so. But it makes a big difference to me. Yesterday, I learned about a Composite pattern, today I learned about the Boulder pattern. And I think the knowledge is deeper this time. I think this is a very good way. Little more involved and time consuming, but at the end, it&#8217;s what stays with you. Try it and learn. \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To learn design patterns is not easy. It&#8217;s one thing to just read about them and think you know them. It&#8217;s another thing to actually know how to use them, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[],"class_list":["post-104","post","type-post","status-publish","format-standard","hentry","category-architecture-design"],"_links":{"self":[{"href":"https:\/\/pragmaticcraftsman.kubasek.com\/wp-json\/wp\/v2\/posts\/104","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pragmaticcraftsman.kubasek.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pragmaticcraftsman.kubasek.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pragmaticcraftsman.kubasek.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pragmaticcraftsman.kubasek.com\/wp-json\/wp\/v2\/comments?post=104"}],"version-history":[{"count":0,"href":"https:\/\/pragmaticcraftsman.kubasek.com\/wp-json\/wp\/v2\/posts\/104\/revisions"}],"wp:attachment":[{"href":"https:\/\/pragmaticcraftsman.kubasek.com\/wp-json\/wp\/v2\/media?parent=104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pragmaticcraftsman.kubasek.com\/wp-json\/wp\/v2\/categories?post=104"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pragmaticcraftsman.kubasek.com\/wp-json\/wp\/v2\/tags?post=104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}