From d5e507933f163f267bb3b19d58f2dbab32a32657 Mon Sep 17 00:00:00 2001
From: Matt Grau <graum@phys.ethz.ch>
Date: Tue, 13 Jul 2021 13:18:02 +0200
Subject: [PATCH] create bad example (multiple sources of truth)

---
 device/device.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/device/device.py b/device/device.py
index ec557c4..ac54456 100644
--- a/device/device.py
+++ b/device/device.py
@@ -2,6 +2,9 @@ class Device:
     __voltage = 0.0
     __current = 0.0
 
+    voltage = None
+    current = None
+
     def __init__(self):
         # code to connect to device
         self.__voltage = 1.0
@@ -10,6 +13,7 @@ class Device:
     def _get_voltage(self):
         # read voltage from device
         voltage = self.__voltage
+        self.voltage = voltage
         return voltage
 
     def _set_voltage(self, new_voltage):
@@ -19,14 +23,15 @@ class Device:
     def _get_current(self):
         # read current from device
         current = self.__curent
+        self.current = current
         return current
 
     def _set_current(self, new_current):
         # write current to device
-        self.__curent = new_current
+        self.__current = new_current
 
     def _calculate_resistance(self):
-        current = self._get_current()
-        voltage = self._get_voltage()
+        current = self.current
+        voltage = self.voltage
         resistance = voltage / current
         return resistance
-- 
GitLab