Re: OO is not that great: many repeated codes



Daniel T. a écrit :
(snip)

I don't feel like others directly addressed the example...

(Python)
class Student:
def driveCarWell(self):
pass

class HouseWife:
def cookDeliciousFood(self):
pass

class Calculator:
def average(self, firstNum, secondNum):
pass

class Professor (Student, HouseWife, Calculator):
pass

Where's the duplication?

I'd certainly not implement it this way in Python.

def driveCarWell(self):
pass

def cookDeliciousFood(self):
pass

def average(self, firstNum, secondNum):
pass

class Student(object):
driveCarWell = driveCarWell

class HouseWife(object):
cookDeliciousFood = cookDeliciousFood

class Calculator(object):
average = average

class Professor(object):
driveCarWell = driveCarWell
cookDeliciousFood = cookDeliciousFood
average = average


Python's functions *are* objects...
.