I completely agree with jvlad's thoughts - for me namespace is ability to
separate two different libraries from each other so that they don't
conflict. I don't need namespaces just to write my own application using
them to be cool, and I probably would never use a namespace for small or
middle size application, but what I will surely do - namespace libraries
witch I will use in my application, so that I don't have to use prefixes for
my application functions and classes.

AndIMHO, I _really_ _don't_ _want_ to remember those complicated rules for
name resolution, importing namespaces. There is category of developers,
witch will make a real mess of this. As I personally see namespaces:

index.php

<?php
require_once('application.php');

namespace Zend {
    require_once('zendframework.php');
}

namespace PDF {
    require_once('tcpdf.php');
}

$loader = new Zend::ZendLoader();
$db = new Zend::ZendDB();
$pdf = new PDF::TCPDF();
$application = new Application();
$application->addHandler('loader', $loader);
$application->addHandler('db', $db);
$application->addHandler('pdf', $pdf);
$application->run();
$application->quit();
?>

Of course that isn't a good example, because Zend framework always has a
class prefix "Zend", but they surely can use a namespace and remove that
Zend in front of classes.

And I don't see any point in "use NamespaceName as OtherName" - I open a
project, there is namespace Foo used for libraries. Then I open some modules
- there is Bar::get() in the code. What will I look for? Namespace Bar,
especialy when many namespaces are used in application. imporing foo as bar
is quite confusing. Yes, we programmers can handle such things, we can learn
from our mistakes, but that's not the reason to make us masochist! I'm
fed-up with teaching people all the time how to properly code in PHP or
clean the code after such people. Really, sometimes PHP core developers
should say to comunity "f*k you, we will do that the proper way" and just
do. People are happy with Java, .NET and so on and nobody is complaining
that they can't import namespace under other name than original (maybe in
some languages you can do that, but I don't code much in other languages, so
I can't say that for sure). This is called "standarts" - everybody knows
that name "Foo" always means "Foo" if "Foo" package is used in application,
and that nobody can import it as "Blah" - they will have to change the
namespace in package itself and that's so stupid , that nobody will do that
(well if they do - don't mess with such people at all).

Reply via email to