Re: What is/is not considered to be good OO programming
Matty <matt+nntp@askm enoquestions.co .uk> wrote in message news:<cGPAb.184 72$lm1.155203@w ards.force9.net >...[color=blue]
> Matty wrote:
>
>[color=green]
> > Wow, it's come back to life again!
> >
> > Asbestos manufacturers everywhere must be looking forwards
> > to this one!
> >
> > ;p
> >
> > Matt[/color]
>
> FWIW, I still think it's better to have 12 different instances,
> rather than 12 different classes <duck />...[/color]
According to the principles of OO you are not supposed to instantiate
an abstract class then feed it the implementation details, you are
supposed to put the implementation details in a subclass. If I were to
use the keyword 'abstract' in the class definition (as PHP 5 will
allow) you will find it impossible to instantiate an abstract class
directly, in which case you MUST use a subclass.
So, if I have 12 database tables each with a totally different set of
implementation details, then (according to the above-mentioned
principle) I must create 12 subclasses. I am right and you are wrong,
so score 1-0 to me :)
[color=blue]
> Not read it all yet,
> just a quick search! I'll have a good read through tomorrow, but
> I do think there aren't sufficient differences between tables in a
> database to justify having a separate class to handle each table,
> when a separate instance of a suitably generic class would handle it
> OK.
>
> I am definitely a TMTOWTDI kind of person, though, and I do agree
> that fundamentally, if the software works, then it's good.
>
> Matt[/color]
If it works then it is not wrong. But if method A is easier to
implement than method B, then (all other things being equal) method A
is better.
Tony Marston
Matty <matt+nntp@askm enoquestions.co .uk> wrote in message news:<cGPAb.184 72$lm1.155203@w ards.force9.net >...[color=blue]
> Matty wrote:
>
>[color=green]
> > Wow, it's come back to life again!
> >
> > Asbestos manufacturers everywhere must be looking forwards
> > to this one!
> >
> > ;p
> >
> > Matt[/color]
>
> FWIW, I still think it's better to have 12 different instances,
> rather than 12 different classes <duck />...[/color]
According to the principles of OO you are not supposed to instantiate
an abstract class then feed it the implementation details, you are
supposed to put the implementation details in a subclass. If I were to
use the keyword 'abstract' in the class definition (as PHP 5 will
allow) you will find it impossible to instantiate an abstract class
directly, in which case you MUST use a subclass.
So, if I have 12 database tables each with a totally different set of
implementation details, then (according to the above-mentioned
principle) I must create 12 subclasses. I am right and you are wrong,
so score 1-0 to me :)
[color=blue]
> Not read it all yet,
> just a quick search! I'll have a good read through tomorrow, but
> I do think there aren't sufficient differences between tables in a
> database to justify having a separate class to handle each table,
> when a separate instance of a suitably generic class would handle it
> OK.
>
> I am definitely a TMTOWTDI kind of person, though, and I do agree
> that fundamentally, if the software works, then it's good.
>
> Matt[/color]
If it works then it is not wrong. But if method A is easier to
implement than method B, then (all other things being equal) method A
is better.
Tony Marston
Comment