Created
June 9, 2019 15:46
-
-
Save jonascheng/ed0f6b2fbee575d416adb0362d3ea89a to your computer and use it in GitHub Desktop.
SOLID-AbstractSerializedEmployeeClass
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import abc | |
import datetime | |
class DBStore(abc.ABC): | |
@abc.abstractmethod | |
def connect(self): | |
return NotImplemented | |
@abc.abstractmethod | |
def serialize(self, first_name: str , last_name: str, birth: datetime, hourly_rate: int, labor_hours: int): | |
return NotImplemented | |
class Employee: | |
// ... | |
def save(self, db: DBStore): | |
db.connect() | |
db.serialize(self._first_name, self._last_name, self.birth, self._hourly_rate, self._labor_hours) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment