I have been a Java programmer for 4,5 years. Now I've switched to Python (and the main reason is that I'm now a freelancer and I work alone). I provide source code to my costumers and sometimes I have to motivated my design choices. Now to the question. I have to support my design choice:
class Base(object):
def foo(self):
self.dosomethig(self.clsattr1)
self.dosomethig(self.clsattr2)
class Derived(Base):
clsattr1 = value1
clsattr2 = value2
Base class is always meant to be extended or derived.
My customer (a java programmer) argues that my approach is not elegant from an OO point of view.
He claims that the following approach is better:
class Base(object):
def __init__(self, clsattr1, clsattr2):
self.clsattr1 = clsattr1
self.clsattr2 = clsattr2
def foo(self):
self.dosomethig(self.clsattr1)
self.dosomethig(self.clsattr2)
class Derived(Base):
def __init__(self):
super(Derived, self).__init__(value1, value2)
I realize that second approach is much more elegant than the first one, but I told him that the first approach is much more handy. I told him I do not see any issue, but he is not convinced. Is the first approach so bad? And why?