Search code examples
oopdesign-patternsobject-oriented-analysis

Concrete classes with different required properties


I am implementing a 2 step authentication system, to send the sms I have multiple provider (aws, twilio and on prem). I created an interface ISMSService and have three concrete classes implementing the method "send" in the interface. My problem is that each service like aws or twilio requires different setup pararmeters to send a message so I cannot define those in the interface. I can access those parameters in the implementation of "send" from the web.config but I don't want to do that. Is there any abstract way to do that and still be able to send the sms using ISMSService reference?


Solution

  • You could have your send method take a Map options. e.g.

    public void send(Map<String, Object> options) { }