principles:dependency_inversion_principle
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
principles:dependency_inversion_principle [2018-09-26 11:29] – [Example 1: Furnace] 62.228.239.6 | principles:dependency_inversion_principle [2018-09-26 11:37] – [Example 2: Client Repository] 62.228.239.6 | ||
---|---|---|---|
Line 104: | Line 104: | ||
==== Example 2: Client Repository ==== | ==== Example 2: Client Repository ==== | ||
- | Let's say the high-level module (your business logic), wants to be able to add or remove users to the database. Instead of it talking to the database directly, it defines an interface called UserRepository which contains the methods the business logic needs. Then a MySQLUserRepository concretion, implements that interface and uses a database library to submit the queries. Since the interface is decided by the business logic, the high-level policy is protected from changes in the database library. More over, since the interface was defined by the business logic, it does not reveal anything about the underlying implementation, | + | Let's say the high-level module (your business logic), wants to be able to add or remove users to the database. Instead of it talking to the database directly, it defines an interface called UserRepository which contains the methods the business logic needs. Then a MySQLUserRepository concretion, implements that interface and uses a database library to submit the queries. Since the interface is decided by the business logic, the high-level policy is protected from changes in the database library. More over, since the interface was defined by the business logic, it does not reveal anything about the underlying implementation, |
===== Description Status ===== | ===== Description Status ===== | ||
/* Choose one of the following and comment out the rest: */ | /* Choose one of the following and comment out the rest: */ |
principles/dependency_inversion_principle.txt · Last modified: 2021-10-18 21:23 by christian