{"id":307,"date":"2014-05-05T22:18:35","date_gmt":"2014-05-05T22:18:35","guid":{"rendered":"http:\/\/andypalmer.com\/?p=307"},"modified":"2014-05-05T22:18:35","modified_gmt":"2014-05-05T22:18:35","slug":"fragility-of-design-pattern-named-classes","status":"publish","type":"post","link":"https:\/\/andypalmer.com\/2014\/05\/fragility-of-design-pattern-named-classes\/","title":{"rendered":"Fragility of Design-Pattern Named Classes"},"content":{"rendered":"

Design patterns are about how<\/em> something does it’s job, rather than why<\/em>. Using a design pattern name in the name of a class makes it quite fragile. For example, if you have called all your classes BlahBlahState<\/code>, then refactoring to a Strategy<\/code> is quite invasive, but if it’s phrased in terms of the why, then the names don’t need to change.<\/p>\n

A good analogy here is the relation of unit tests to implementation; you should be able to change the internal implementation of the class without changing the tests<\/em>. If you can’t, then the tests are too brittle. Likewise, you should be able to change the implementation without changing the class name<\/em>; if your class name is tied to the implementation, through the pattern name, then it’s too brittle.<\/p>\n","protected":false},"excerpt":{"rendered":"

Design patterns are about how something does it’s job, rather than why. Using a design pattern name in the name of a class makes it quite fragile. For example, if you have called all your classes BlahBlahState, then refactoring to a Strategy is quite invasive, but if it’s phrased in terms of the why, then […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/posts\/307"}],"collection":[{"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/comments?post=307"}],"version-history":[{"count":3,"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/posts\/307\/revisions"}],"predecessor-version":[{"id":311,"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/posts\/307\/revisions\/311"}],"wp:attachment":[{"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/media?parent=307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/categories?post=307"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/tags?post=307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}