|
Posted by Mark Twain on 09/30/33 11:30
In article <uM_7f.48280$yS6.27532@clgrps12>,
"Daedalus.OS" <ng@nxstream.net> wrote:
> Ok first I'm pretty new to OOP, so my question may sound stupid to some of
> you. If the only answer you can provide is "get a book about OOP" then don't
> loose your time and mine cause it's already ordered. I'm just too curious
> about this one to wait for the book.
>
> I would like to know is if it's good php programming practice to use
> abstract classes instead of singleton classes. For exemple a login class.
> I've made one as an abstract class and now I'm wondering if it's a good
> idea. Technically there would be only one login object so I thought having
> this object was pointless and I use an abstract class with everything in it
> static. Is it a good or a bad idea and why? In what situation the difference
> between having only one object and no object at all with only static
> functions and variables would lead to use one more the other? Or why in a
> PHP context would I prefer to have a single object rather than what I would
> call a "static virtual object".
>
>
> Thanks,
> Dae
Part of the point of creating an abstract class is so that you can use
it in other projects. So while you may only have one login object, you
might wind up down the road (if you are lucky) with a hundred clients
who all need projects with one login object.
And then comes a day when you get a project where you need five login
objects, and you suddenly become glad you wrote the class.
It's a cost-benefit thing: you have to weigh the time you spend on
overhead against the projected savings in the future, which can
sometimes be a bit difficult.
mt
[Back to original message]
|