I have a Python class that has several "major" methods, which successively modify one of its attributes, e.g.
def method1(self):
# modify an attribute of self
return self
def method2(self):
# modify the same attribute of self
return self
Each of these core methods, in turn, calls multiple "helper" class methods that also modify the same attribute, i.e.
def method1(self):
self = self.helper_method1().helper_method2()
return self
def method2(self):
self = self.helper_method3().helper_method4()
return self
Is there a consensus on where (on what level) these "helper" methods should be defined inside a class?
I.e. is this:
def helper_method1_to_be_called_by_method1(self):
# modify at attribute of self
return self
def helper_method2_to_be_called_by_method1(self):
# modify at attribute of self
return self
def method1(self):
self = self.helper_method1().helper_method2()
return self
preferable to this (or vice versa):
def method1(self):
def helper_method1_to_be_called_by_method1(self):
# modify at attribute of self
return self
def helper_method2_to_be_called_by_method1(self):
# modify at attribute of self
return self
self = self.helper_method1().helper_method2()
return self
Or is there a third strategy that works best in terms of performance, ease of readability, and maintenance?