Why? I think namespace is a good method to seperate classes. 6 1517
Yarco wrote: Why? I think namespace is a good method to seperate classes.
The early PHP5 alpha releases supported namespaces, but as the
developers never got it to work properly, they left it out in the PHP
5.x branch.
JW
On Mon, 10 Oct 2005 12:19:47 +0200, Janwillem Borleffs <jw@jwscripts.com>
wrote: Yarco wrote: Why? I think namespace is a good method to seperate classes.
The early PHP5 alpha releases supported namespaces, but as the developers never got it to work properly, they left it out in the PHP 5.x branch.
The text of the proposed namespace syntax is still in the PHP source
distribution, see $PHP_SRC/Zend/RFCs/002.txt - although in the header it says
"Status: declined".
--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
"Yarco" <ya*****@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com... Why? I think namespace is a good method to seperate classes.
Giving each class a different name is usually good enough. If you have
classes with identical names from different 3rd party suppliers then keep
them in different directories. Personally I cannot see what all the fuss
with namespaces is about. I have been programming for 30 years with a
variety of 2nd, 3rd and 4th generation languages and I have never used
namespaces.
Perhaps that is the only solution you have been taught, but it is certainly
not the only solution out there.
--
Tony Marston http://www.tonymarston.net
> Giving each class a different name is usually good enough...
It may get longer...
For example, non-namespace:
class Tony_db
{
const MYSQL='mysql';
//...
}
So, i should use Tony_db::MYSQL to use it.
But if i have namespace.
namespace Tony
{
class db
{
const MYSQL='mysql';
}
}
and then, i can coding:
using namespace Tony;
db::MYSQL
So...there might be:
$db = Tony_db::getInst(Tony_db::MYSQL);
vs
using namespace Tony;
$db = db::getInst(db::MYSQL);
And when using namespace myself, i can only change the namespace "Tony"
to "Yarco".
But when change class, i should do it line by line, or using some
automatic modifier.
another benefit of being able to use namespaces is providing another
layer of encapsulation, defining visibility for classes, hiding
unneeded info from the namespaces different than the current.
I think that's more important than the name collision. About the
naming,using frameworks or 3rd party modules etc. results in name
collisions most of the time, and working as a team may result in weird
names.
Eg. Namespace A
{
private class B
{}
public Class c
}
Namespace D
{
private class E
{
instC=new C(); // OK
instB=new B(); // Not Accessible
}
} This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: lawrence |
last post by:
To call I would do something like:
$headline = McSelectJustOneField::callDatastore("cbHeadline");
Is this the correct use of the static keyword, to implement a
Singleton design?
|
by: MDoyle |
last post by:
Here is the easiest question you’ll get all day from a complete newbie.
I installed Visual Studio on my laptop last night and have been tryin
to write my very first C# programs this morning. I’m...
|
by: dotNETnews |
last post by:
Little confused...
When I declare a namespace variable in module I can use it anywhere in the
project. That's clear.
I read a book in which the author said that namespace variables can be...
|
by: Pep |
last post by:
Is it best to include the code "using namespace std;" in the source or
should each keyword in the std namespace be qualified by the namespace tag,
such as
std::cout << "using std namespace" <<...
|
by: Karl Groves |
last post by:
I'm looking to make a keyword array.
Let's say I have the following array:
$words = array
("foo","lorem","foo","ipsum","bar","foo","dolor","sit","foo","bar","amet","
lorem");
I'd like to...
|
by: toton |
last post by:
Hi,
I have some enum (enumeration ) defined in some namespace, not inside
class. How to use the enum constant's in some other namespace without
using the whole namespace.
To say in little...
|
by: DaTurk |
last post by:
Hi,
I have an interesting issue, well, it's not really an issue, but I'd
like to understand the mechanics of what's going on. I have a file,
in CLI, which has a class declared, and a static...
|
by: Peng Yu |
last post by:
Hi,
I'm wondering if there is something in namespace like the 'private'
keyword in class?
I want to define some class or function that can only be used within
that namespace.
Thanks,
Peng
|
by: Luna Moon |
last post by:
I am reading the book "C++ Annotations", and here is a quote from the
book:
Namespaces can be defined without a name. Such a namespace is
anonymous and it restricts the
visibility of the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |