3 ms·
DI services are usually abstracted behind interfaces - and most systems allow you to replace the service interface implementation at runtime. So if you have a
by DaiPlusPlus 7y ago
DI services are usually abstracted behind interfaces - and most systems allow you to replace the service interface implementation at runtime.
So if you have a class that uploads files to a cloud storage provider - it would make use of IStorageProvider, and you might have AmazonS3StorageProvider, AzureBlobStorageProvider, LocalDiskStorageProvider, and for testing you would have DevNullStorageProvider.
A program using DI without interfaces with different implementations is missing the other advantages of DI.