Tuesday, March 5, 2019

Help Pinning Down Design Pattern

I am working on the architecture for a new project and I'm using what I imagine must be a very common pattern, but I can't pin down what exactly I would label it. Here is a simple example (parameters and other details omitted for simplicity):

public interface ISupportCaseProvider { bool CanGetSupportCase(); SupportCase GetSupportCase(); } public class SupportCaseService { private readonly IEnumerable<ISupportCaseProvider> _providers; public SupportCaseService(IEnumerable<ISupportCaseProvider> providers) { _providers = providers; } SupportCase GetSupportCase() { // foreach provider in _providers, test and possibly invoke } } 

In the above example, I might have a different ISupportCaseProvider implementation for each business unit in my organization. These are all injected into SupportCaseService, which handles "testing" each of the providers via CanGetSupportCase() to determine which provider to use, then returns the result to the caller.

So I guess, here are my questions or areas where I'm looking for some feedback:

  1. What would you label this type of pattern (i.e. Adapter, Proxy, Bridge, Facade, etc)? I mainly want to ensure I name these interfaces and classes in a way that makes it very clear what path to take when extending the app (e.g. SupportCaseService vs SupportCaseAdapter vs SupportCaseProxy, etc) as I will eventually be handing this app off to a totally different team to maintain. It seems to share tenets of multiple patterns, but maybe that is just my inexperience showing.

  2. Does anyone have any suggestions on better ways to solve the "multiple implementation" problem? Is a CanDoX() "test" method the right way to go about this? I'm the only developer on my "team", so it can become an echo chamber pretty quickly and I definitely value hearing about other ways people are skinning the cat, so to speak.

Any and all thoughts are welcomed. Thank you for your time!

Help Pinning Down Design Pattern Click here
  • Blogger Comment
  • Facebook Comment

0 comments:

Post a Comment

The webdev Team