Skip to content
Snippets Groups Projects
Commit d5e50793 authored by Matt Grau's avatar Matt Grau
Browse files

create bad example (multiple sources of truth)

parent e64e3640
No related branches found
No related tags found
No related merge requests found
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment