Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 5.dip.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def post(self, url, options: dict):
This design violates DIP A: High-level modules should not depend on low-level level modules. It should depend upon its abstraction.

Ths Http class is forced to depend upon the XMLHttpService class.
If we were to change to change the Http connection service, maybe we want to connect to the internet through cURL or even Mock the http service.
If we were to change the Http connection service, maybe we want to connect to the internet through cURL or even Mock the http service.
We will painstakingly have to move through all the instances of Http to edit the code and this violates the OCP principle.

The Http class should care less the type of Http service you are using. We make a Connection interface:
Expand Down Expand Up @@ -83,4 +83,4 @@ def request(self, url: str, options:dict):

Also, this DIP will force us not to violate the Liskov Substitution Principle:
The Connection types Node-XML-MockHttpService are substitutable for their parent type Connection.
"""
"""