From 8a0ca44217014202094437ef6b8fd73b2e55dcea Mon Sep 17 00:00:00 2001 From: kimo722504 Date: Wed, 9 Dec 2020 23:25:57 +0900 Subject: [PATCH] Modify minor typo and type hint --- 1.srp.py | 6 +++--- 5.dip.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/1.srp.py b/1.srp.py index cd27e8b..fda52a2 100644 --- a/1.srp.py +++ b/1.srp.py @@ -44,9 +44,9 @@ def save(self, animal: Animal): class Animal: def __init__(self, name: str): - self.name = name + self.name = name - def get_name(self): + def get_name(self) -> str: pass @@ -75,7 +75,7 @@ def __init__(self, name: str): self.name = name self.db = AnimalDB() - def get_name(self): + def get_name(self) -> str: return self.name def get(self, id): diff --git a/5.dip.py b/5.dip.py index fb3182e..adc6e4f 100644 --- a/5.dip.py +++ b/5.dip.py @@ -22,13 +22,13 @@ def __init__(self, xml_http_service: XMLHttpService): def get(self, url: str, options: dict): self.xml_http_service.request(url, 'GET') - def post(self, url, options: dict): + def post(self, url: str, options: dict): self.xml_http_service.request(url, 'POST') """ Here, Http is the high-level component whereas XMLHttpService is the low-level component. This design violates DIP A: High-level modules should not depend on -low-level level modules. It should depend upon its abstraction. +low-level modules. It should depend upon its abstraction. Ths Http class is forced to depend upon the XMLHttpService class. If we were to change the Http connection service, maybe we want to connect to the internet @@ -56,7 +56,7 @@ def __init__(self, http_connection: Connection): def get(self, url: str, options: dict): self.http_connection.request(url, 'GET') - def post(self, url, options: dict): + def post(self, url: str, options: dict): self.http_connection.request(url, 'POST') """