preemptive OOP?

Erik Johnson ejatwellkeeperdotcom
Thu Sep 28 20:54:14 CEST 2006


> class MyNotebook(wx.Notebook):
>      def __init__(self, parent):
>          wx.Notebook.__init__(self, parent)

> So my question in general is, is it a good idea to default to an OOP
> design like my second example when you aren't even sure you will need
> it? I know it won't hurt, and is probably smart to do sometimes, but
> maybe it also just adds unnecessary code to the program.

    My feeling is that there is no good reason to add the complexity of your
own custom classes if they provide no additional data or behaviour. If you
know you have plans to add your own attributes and/or methods to MyNotebook
soon, there's no harm in doing this now, but why? You can always create your
own custom subclass at the point when you have something of value to add and
through the mircale of polymorphism, it will function everywhere a Notebook
would.

-ej





More information about the Python-list mailing list