What are high-level modules and low-level modules?

I know this is an exact duplicate of the link below.

What are "High Level Modules" and "Low Level Modules" (in the context of the dependency inversion principle)?

But after reading, I do not understand what it is.

High level modules are abstract classes and Interfaces ? 
+4
source share
1 answer

A high-level module is an interface / abstraction that will be consumed directly by the presentation layer. A low level, on the other hand, is a bunch of small modules (subsystems) that help a high level do its job. The example below is a high-level module. I excluded dependency constructor injection for a shorter sample.

 public class OrderService : IOrderService { public void InsertOrder(Order ord) { if(orderValidator.IsValidOrder(ord) { orderRepository.InsertNew(ord); userNotification.Notify(ord); } } } 

And one of the low-level modules ( OrderValidator ):

 public class OrderValidator : IOrderValidator { public bool IsValidOrder(Order ord) { if(ord == null) throw new NullArgumentException("Order is null"); else if(string.IsNullOrEmpty(ord.CustomerId)) throw new InvalidArgumentException("Customer is not set"); else if(ord.Details == null || !ord.Details.Any()) throw new InvalidArgumentException("Order detail is empty"); } } 
+6
source

Source: https://habr.com/ru/post/1480857/


All Articles