jeudi 27 juillet 2023

Interface to return Generic type

I have an interface that returns a Connection. I've changed to Object, because I need to return sometimes a Connection and sometimes a MongoDatabase object from Mongo. My poor ideia was to change this method to Object, like this:

Object getConnnection(String uri);

Is a poor design? Any suggestion to improve this aproach? Thanks a lot for any suggestion.

Aucun commentaire:

Enregistrer un commentaire