I'm having a hard time making a design decision
I have a class in python, that processing form data, this data is very similar to other form data, and so I'm refactoring it into it's own object so it can be reused by the other classes.
The delima is weather to make this formprocessor a member of the classes or a parent of the classes.
please correct me if this terminology is wrong, here is what I'm torn between:
monolithic inheritance based classes:
class FormProcessor(object):
def post(self):
# ... process form data
class PageHandler(RequestHandler,FormProcessor):
def get(self):
# show page
or the more modular member based classes:
class FormProcessor(object):
def process(self):
# ... process form data
class PageHandler(RequestHandler):
def __init__(self):
self.processor = FormProcessor()
def get(self):
# show page
def post(self):
self.processor.process(self.postdata)
I'm leaning toward the second but I'm not sure what the consequences could be down the road in terms of maintainability. The reason I'm leaning toward it is that, I like to think of the processing as an action that takes place, not as a main part of the PageHandler, so this makes sense to make it a member object, instead of a parent.
It bothers me that when classes interit functionality it ends up with a very long list of functions on an instance, I'm trying to categorize them better so the program is understandable and reflects the system that it is modeling.
look forward to any advice on this issue