jeudi 6 juin 2019

Granularity of Interface

on my work today i came to struggle with the slice of my Interfaces.

To maintain some masterdata in my application, i build an context. This context takes an dataprovider to take the Information it needs and bring it to an strategy to persist.

In first try i build an Method in my context for setting the Dataprovider. E. G. one file based and one from database.

Context->setData(MyProvider->getData() ) ;

The dataprovider needs some different settings to Do the work. The Filebased need the Filepath and the databaseprovider an Modelobject.

Now im Not sure, what's the best way of defining the interface. Make an general Interface "Provider" and care about the return type of the getData Method. Or go with inheritance an build a special interface for Fileprovider and on for the Database.

Interface Fileprovider extends IProvider { void setPath(String Path) ;} 

Or third possibility just do a standalone interface for every Provider.

Thanks for you toughts

Aucun commentaire:

Enregistrer un commentaire