The Dependency Inversion Principle say:
- High-level modules should not depend on low-level modules. Both should depend on abstractions.
- Abstractions should not depend upon details. Details should depend upon abstractions.
How can I practically find the High-level and the Low-level modules in my applications, is there any clear definition for them?
This is how usually I refer them:
High Level Module --> this module represent more business aspect rather than technical aspect. It can be refered as an abstraction rather than implementation, and usually achieved through interfaces.
Some example maybe:
RegisterAccount,PostAnswer,PostQuestion,AddComment,InsertComment.Since Low Level Module represent more technical aspect rather than the business aspect. Say for example we take the
InsertCommentHLM. The LLM should be:A High Level Module can be a Low Level Module in another context. Taking another example,
AddComment's LLM should be:InsertComment)The same apply for other HLM as well.