I have been a Java programmer for 4.5 years. Now I have switched to Python (and the main reason is that I am now a freelancer and I work alone). I provide source code to my clients, and sometimes I have to motivate my design decisions. 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
The base class must always be extended or derived. My client (a Java programmer) claims that my approach is not elegant from an OO point of view. He argues 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 understand that the second approach is much broader than the first, but I told him that the first approach is much more convenient. I told him that I did not see any problems, but he was not convinced. Is the first approach so bad? And why?