I have a code with the same structure as bellow:
class parent(Object):
def method1(self,name):
raise NotImplementedError("Subclasses should implement this")
class child1(parent)
def method1(self, name, company)
print(name + ' ' + company)
print(name + '!!!')
name = 'Thanks' + name
class child2(parent)
def method1(self, name, company)
print(name + '----' + company)
print(name + '!!!')
name = 'Thanks' + name
Here I have 2 childrer that override the method of the parent. The problem is that the children classes share a code that is the same ( the second and third instructions in method1) . Is this code correct even so ? How to improve this code so that the code is not repeated?