Created
December 29, 2014 16:56
-
-
Save derwolfe/173d067fdfa772254760 to your computer and use it in GitHub Desktop.
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
# File: data_handlers.py | |
from models import MyDataObject | |
class MyDataHandler: | |
""" responsible for working on the data only.""" | |
def __init__(self, data_object): | |
self.data_object = data_object | |
def mult_data_by_two(self): | |
return self.data_object.numeric_data * 2 |
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
#File: models.py | |
class MyDataObject: | |
"""responsible for manipulating, transforming data""" | |
def __init__(self): | |
self.numeric_data = 0 | |
# this isn't really necessary in python, as one normally just sets/gets python attributes. | |
# but, let's say that set does some crazy translation of the data, | |
# then it makes more sense to split into its own method | |
def set_data(self, new_data): | |
self.numeric_data = new_data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment