Skip to content

Instantly share code, notes, and snippets.

@carlosble
Created July 8, 2020 16:03
Show Gist options
  • Save carlosble/2e5daa2f2be6c24d31b5d0c2ecf62ca5 to your computer and use it in GitHub Desktop.
Save carlosble/2e5daa2f2be6c24d31b5d0c2ecf62ca5 to your computer and use it in GitHub Desktop.
class Sensor:
"""Lo vamos a simular"""
def is_detecting_movement(self) -> bool:
pass
class Recorder:
"""Lo vamos a simular"""
def start_recording(self):
pass
def stop_recording(self):
pass
class Controller:
sensor: Sensor # dependency
recorder: Recorder # dependency
def __init__(self, sensor: Sensor, recorder: Recorder):
self.sensor = sensor
self.recorder = recorder
def record_movement(self):
if self.sensor.is_detecting_movement():
self.recorder.start_recording()
else:
self.recorder.stop_recording()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment