note 85589 deleted from language.namespaces.definition by cmb
| From: | cmb@php.net | Date: | Fri, 13 Mar 2020 16:23:50 +0000 |
| Subject: | note 85589 deleted from language.namespaces.definition by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-214327@lists.php.net to get a copy of this message | ||
Note Submitter: David Drakard
----
I agree with SR, the new namespaces feature has solved a number of problems for me which would have
required horrible coding to solve otherwise.
An example use:
Say you are making a small script, and write a class to connect to a database, calling it
'connection'. If you find your script useful and gradually expand it into a large
application, you may want to rename the class. Without namespaces, you have to change the name and
every reference to it (say in inheriting objects), possibly creating a load of bugs. With namespaces
you can drop the related classes into a namespace with one line of code, and less chance of errors.
This is by no means one of the biggest problems namespaces solve; I would suggest reading about
their advantages before citicising them. They provide an elegant solutions to several problems
involved in creating complex systems.