{"id":4970,"date":"2014-03-30T17:19:11","date_gmt":"2014-03-30T17:19:11","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-to-switch-between-implementations-of-my-somethingmanager-class-collection-of-common-programming-errors\/"},"modified":"2014-03-30T17:19:11","modified_gmt":"2014-03-30T17:19:11","slug":"how-to-switch-between-implementations-of-my-somethingmanager-class-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-to-switch-between-implementations-of-my-somethingmanager-class-collection-of-common-programming-errors\/","title":{"rendered":"How to switch between implementations of my SomethingManager class?-Collection of common programming errors"},"content":{"rendered":"<p>I have an app which has OrgManager interface, which has a yet-to-be-built OrgManagerImpl<\/p>\n<p>The OrgManagerImpl has to go and talk to some REST API 3rd party stuff which we don&#8217;t have access to yet.<\/p>\n<p>So while I am testing the web front end, I have written a mock OrgManagerImpl that implements the OrgManager, but at go-live I will need to swap that implementation over.<\/p>\n<p>However now I am in the situation where I want to have the servlet select its OrgManager implementation dependent on some condition.<\/p>\n<p>Also when I call myOrgManager.findCompany(&#8220;SomeCompanyId&#8221;) I want myOrgManager to go and look at all the possible implementations to find the company and make a big list.<\/p>\n<p>Also I would like when I do myOrgManager.createCompany(company) to prefer one implementation over the others.<\/p>\n<p>I seem to be heading towards a UserManagerManager object&#8230; but I feel that this is likely missing some point of Java or Object orientated design that I should know about.<\/p>\n<p>Can anyone suggest a pattern, or strategy that I should be using instead?<\/p>\n<p>Thanks<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have an app which has OrgManager interface, which has a yet-to-be-built OrgManagerImpl The OrgManagerImpl has to go and talk to some REST API 3rd party stuff which we don&#8217;t have access to yet. So while I am testing the web front end, I have written a mock OrgManagerImpl that implements the OrgManager, but at [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4970","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4970","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4970"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4970\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4970"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4970"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4970"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}