|
Posted by Steve on 09/27/07 20:35
"RageARC" <ragearc@gmail.com> wrote in message
news:1190924835.291494.316860@y42g2000hsy.googlegroups.com...
> On 27 Sep, 17:09, "Steve" <no....@example.com> wrote:
>> "RageARC" <rage...@gmail.com> wrote in message
>>
>> news:1190902180.451714.139430@d55g2000hsg.googlegroups.com...
>>
>> >I use other people's libraries often, but I never had libraries
>> > clashing with each other because of that, so I don't understand what's
>> > the fuss about. An example:
>>
>> >http://www.petitiononline.com/phpns/
>>
>> > Quote:
>> > "We implore you to add support for Namespaces in the next possible
>> > release and to not wait until PHP6."
>>
>> > This is what I don't understand! Why people are so crazy about it.
>>
>> isolation...a key aim in oop in any language. it helps php know what
>> resource you're wanting. if you've ever worked on a project with a couple
>> of
>> other developers, did you ever have it happen that a DEFINE was done with
>> the same name as another was using? you probably found out when both
>> resources were used at the same time (i.e. one script calling two
>> classes,
>> each doing the define). namespaces help avoid things like that - as
>> someone
>> said, collision.
>
> For Database Servers it would be nice to have a namespace for each
> server, and all the functions names in all of them would be exactly
> the same (Come to think of it, that would be awesome xD), what would
> change would be the namespace:
>
> MYSQL::connect...
you're catching on, however that is NOT the way to go architecturally.
specifically, you want an abstract class that defines all of the methods
that will be shared by all db objects. next, you would create your specific
db implementations, implementing the base, abstract db class. finally, you
would create a concrete db class that too, implemented the base, abstract db
class. you would initialize this static concrete db class with a value to
indicate what kind of db it should connect with.
internally, the concrete db class creates an instance of a specific db class
(like mysql) and defers all of it's interfaces (functions, etc.) to the
specific db class...returning values when needed, from the specific db class
to the caller...having the concrete db class as the middle man.
all of that is easier done than said...and is already doable in php.
this kind of isolation is NOT a namespace. it is more considered
'implementation'...the side-effect though, like namespaces, can be
isolation.
clear as mud?
[Back to original message]
|