I am trying to model a design for a C# project. Trying to follow the SOLID principles, this is what I've got so far:

SDKClient class which has three (for this explanation) important properties (IAuthProvider, IHttpProvider and IFileService). The SDKClient should be decoupled, so I am always free to exchange the auth class or http class. That's why I am only using Interfaces (for later DI).

But the real problem lays in the services. So far I was using the client purely for so called "FileServices", which share the same behaviour. Now I am not sure what to do. I am supposed to use new Services, which don't share anything in common with FileServices.

So my question is, is there a way to generalize it to something like IService, or is this the wrong way, are maybe some factories the right solution here, or shouldn't the service be in the SDKClient?

I am pretty inexperienced in software design, that's why I am hoping for really neat solutions/ideas.

If my explanation wasn't sufficient, just ask me questions, about the points you couldn't understand.


One could make it generic:

public interface IService<in TRequest, out TResponse>
    TResponse Execute(TRequest request);

public interface IAsyncService<in TIn, TOut>
    Task<TOut> ExecuteAysnc(TIn request);

Basically, we send something in and get something back. Does it use the file system, call a web service, call a database, that's up to the implementation!

If it does use the file service, then the IService implementation will have an IFileService parameter in the constructor. So, each service could have additional dependencies as needed depending on what they are doing.

  • thanks seems inetresting for generalizing the IService. However, would this be the usual way of handling a such (unusual) problem, or would it be better to seperate into more kinds of clients? – user3125470 Mar 23 '17 at 15:27
  • @User - Interface design is somewhat of a grey area, I am not sure if this is the usual way, but I think it is one possibility to solve the issues raised in your question. – Jon Raynor Mar 23 '17 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.