I am using Dependency Injection. Say that I has an OrderService class like this:
public class OrderService{
public OrderService(
IOrderValidator validator
, IOrderRepository repository
, IOrderNotificator notificator){
//assign global fields
}
public void SubmitOrder(Order ord){
if(validator.IsOrderValid(ord)){
repository.InsertNew(ord);
notificator.Notify(ord);
}
}
}
Now I wonder to create a facade class for example TypeAOrderService
, as inherited by OrderService, with components declared in constructor such as:
public class TypeAOrderService : OrderService{
public TypeAOrderService() : base(
new OrderValidator(),
new OrderRepository(),
new OrderNotificator()) { }
}
(Note that the implementation with injected component complexity is not important here, an adapter pattern
also acceptable to replace inheritance though).
There may be downsides here because we don't define the dependency at composition root. However I wonder whether it is acceptable in some situation. Especially at framework component
when it is rather weird to use the framework by accessing the DI Container and resolve it yourself.
Update:
As mentioned in comment, currently I don't use any IOC container. My perspective is, it is weird to use IOC container in Framework, since it will means that every application uses the framework will need to use IOC container. If my perspective is wrong, feel free to correct me.
What I am refering as the framework example is such as System.Windows.Forms.Form
where I don't use any IOC container and don't determine the dependency.