many client-specific interfaces are better than one general-purpose interface.
During interviews when we talk about these principles, candidates try to glide over this one very quickly. People usually understand this principle, and as a result it is considered to be easier to digest even by junior developers. Imagine the surprise on their face, when I ask them “why?”, “convince me that I should respect this principle”. I’m interested in their reasoning to discover their level of understanding. Like the other principles, you will understand it better if you try to not respect it.
In out last example the GeoPaymentModifier was selecting the closest warehouse. Because the closest might not have the ordered good, this can become a more complex task. The responsibility of the GeoPaymentModifier should be to know what amount to charge not to know how to select the best candidate warehouse.
To raise a bit the difficulty, let’s also consider that the warehouse info and their stock is stored in the database. The database abstraction will look something like this:
interface IDataStorageService
{
IQueryable<UserInfo> Users { get; }
IQueryable<ClientInformation> Clients { get; }
IQueryable<Order> Orders { get; }
IQueryable<WarehouseInfo> Warehouses { get; }
void CreateOrder(Order order);
}