Skip to content

Instantly share code, notes, and snippets.

@derwolfe
Created December 29, 2014 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save derwolfe/173d067fdfa772254760 to your computer and use it in GitHub Desktop.
Save derwolfe/173d067fdfa772254760 to your computer and use it in GitHub Desktop.
# 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
#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
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment