Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 8 months ago. Improve this question Take a look on that pseudocode As service locator is considered as anti pattern, how to avoid it in this case?
Tag: design-patterns
Design pattern to reduce cyclomatic complexity
I have to send invoices to cutomers through the related customer’s API. Each customer chooses how to be contacted (email, fax, sms…). My problem is that each time I add a new “contact type” I increase the cyclomatic complexity of my script. Here is my code : As you can see the switch statement of InvoiceSender::send is increased each time
Is there a name for this ‘pattern’?
I recently encountered a situation where it was useful to create a lazy-loading version of a class by wrapping its factory. I’d like to do some research to find out if there are any issues I hadn’t …
Dependency injection on dynamically created objects
I’m using reflection to test if a class has a particular parent class and then returning an instance of it. I want to be able to unit test these instantiated objects but I don’t know if there is any way to use dependency injection in this case. My thought was to use factories to get dependencies. Is the factory pattern
What’s the difference between Singleton and Registry design pattern
I have some confusion between those two patterns: singleton Check if the instance exists return it, or create a new one. Registry Check if the instance exists return it, or create a new one and store it. What the difference between them? Answer Both are about instance control. The difference is that Singleton allows only one instance of a given