473,703 Members | 2,660 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP global namespace clogged up

PHP puts most of its functions into a big flat global namespace.

That leads to short function names - but creates a namespace
minefield for programmers.

Lots of the functions are legacies from the days before PHP
got object-oriented features.

For instance we currently have:

strstr(haystack , needle)

....instead of something like:

haystack -> find(needle);

To clean up the existing mess, many new functions need to
be created as member function of the appropriate objects -
and most of the old functions in the global namespace need
deprecating.

Does anyone think the existing mess will ever get cleaned up?

Or is PHP's function namespace too shafted at this stage to
ever be repaired?
--
__________
|im |yler http://timtyler.org/ ti*@tt1lock.org Remove lock to reply.
Jul 17 '05 #1
88 5132
"Tim Tyler" wrote:
PHP puts most of its functions into a big flat global namespace.

That leads to short function names - but creates a namespace
minefield for programmers.

Lots of the functions are legacies from the days before PHP
got object-oriented features.

For instance we currently have:

strstr(haystack , needle)

....instead of something like:

haystack -> find(needle);

To clean up the existing mess, many new functions need to
be created as member function of the appropriate objects -
and most of the old functions in the global namespace need
deprecating.

Does anyone think the existing mess will ever get cleaned up?

Or is PHP’s function namespace too shafted at this stage to
ever be repaired?


I think you have a valid point. However, the old functions cannot
easily be retired due enormous legacy code base out there. So the
question then becomes, can we have two sets of functions.

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-global-n...ict145545.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=487021
Jul 17 '05 #2
*** steve escribió/wrote (1 Sep 2004 16:02:51 -0400):
I think you have a valid point. However, the old functions cannot
easily be retired due enormous legacy code base out there. So the
question then becomes, can we have two sets of functions.


I'm not sure of what the original poster meant. Should we replace...

$a=trim($b);

.... with...

$aux=new StringFunctions ();
$a=$aux->trim($b);
:-?

--
--
-+ Álvaro G. Vicario - Burgos, Spain - ICQ 46788716
+- http://www.demogracia.com (la web de humor para mayores de 100 años)
++ «Sonríe, que te vamos a hacer una foto para la esquela»
--
Jul 17 '05 #3
I think you're talking crap. Just because other languages have namespaces
does not mean that PHP *must* have them as well. I have programmed for
several decades in a variety of languages that did not have namespaces, so I
have learned how to work without them. I suggest you do the same.

If you really *must* have a language that incorporates namespaces then go
and use one, but leave PHP alone.

I get pretty cheesed off when some geek says "I'm trying to learn PHP after
using language X, but I am finding it difficult because PHP does things
differently. Why can't it be more like X?"

I have groundbreaking news for all you geeks - PHP is not the same as
language X because IT IS DIFFERENT. If it was the same then there would be
no point. Different languages are different, so get used to the differences
and STOP COMPLAINING.

--
Tony Marston

http://www.tonymarston.net

"Tim Tyler" <ti*@tt1lock.or g> wrote in message news:I3******** @bath.ac.uk...
PHP puts most of its functions into a big flat global namespace.

That leads to short function names - but creates a namespace
minefield for programmers.

Lots of the functions are legacies from the days before PHP
got object-oriented features.

For instance we currently have:

strstr(haystack , needle)

...instead of something like:

haystack -> find(needle);

To clean up the existing mess, many new functions need to
be created as member function of the appropriate objects -
and most of the old functions in the global namespace need
deprecating.

Does anyone think the existing mess will ever get cleaned up?

Or is PHP's function namespace too shafted at this stage to
ever be repaired?
--
__________
|im |yler http://timtyler.org/ ti*@tt1lock.org Remove lock to reply.

Jul 17 '05 #4
.oO(Tim Tyler)
Lots of the functions are legacies from the days before PHP
got object-oriented features.
OOP is only an add-on, not a replacement for "legacy" functions.
For instance we currently have:

strstr(haystack , needle)

...instead of something like:

haystack -> find(needle);
Why to use OOP if it's not really necessary?
To clean up the existing mess,
What mess?
many new functions need to
be created as member function of the appropriate objects -
and most of the old functions in the global namespace need
deprecating.
Why? If you want to have objects all over use Java. PHP allows you to
write code with OOP or without, whatever you like.
Does anyone think the existing mess will ever get cleaned up?

Or is PHP's function namespace too shafted at this stage to
ever be repaired?


I have no problem with it (only little problem I have are the different
styles in function names, fooBar() vs. foo_bar()).

Micha
Jul 17 '05 #5
.oO(Alvaro G. Vicario)
I'm not sure of what the original poster meant. Should we replace...

$a=trim($b);

... with...

$aux=new StringFunctions ();
$a=$aux->trim($b);


Pfff ...

$aux = TypeHandlerFact ory::createInst ance('string');
$a->setValue($au x->trim($b->getValue())) ;

This is pretty simple and much more readable ...

SCNR
Micha
Jul 17 '05 #6
On Wed, 1 Sep 2004 18:54:04 GMT, Tim Tyler <ti*@tt1lock.or g> wrote:
PHP puts most of its functions into a big flat global namespace. Lots of the functions are legacies from the days before PHP
got object-oriented features.

For instance we currently have:
strstr(haystack , needle)
...instead of something like:
haystack -> find(needle);

To clean up the existing mess, many new functions need to
be created as member function of the appropriate objects -
and most of the old functions in the global namespace need
deprecating.

Does anyone think the existing mess will ever get cleaned up?

Or is PHP's function namespace too shafted at this stage to
ever be repaired?


I agree that some form of namespacing would have really helped -
personally it's my biggest disappointment with php 5.

However, deprecating everything would shaft all the current non-OO
scripts. This would be a total disaster. I like the hybrid nature of
PHP as it stands.

I'd like to see *new* functions appear namespaced somehow, though, at
the moment you have no assurance of backwards compatibility at all,
since if I've named a function xml_do_somethin g(), next release might
add a new extension with an identically named function.

I'm just hacked off that packages are about the only Java feature that
*didn't* make it in.

Jul 17 '05 #7
Michael Fesser <ne*****@gmx.ne t> wrote or quoted:
.oO(Tim Tyler)
Lots of the functions are legacies from the days before PHP
got object-oriented features.
OOP is only an add-on, not a replacement for "legacy" functions.
For instance we currently have:

strstr(haystack , needle)

...instead of something like:

haystack -> find(needle);


Why to use OOP if it's not really necessary?


OOP is essential sometimes.

Why provide OOP features - and then fail to use the in your library
and instead litter it with procedural function calls?

No good reason. PHP is the way is is due to historical legacy -
not due to intelligent design.
To clean up the existing mess,


What mess?


As I originally described it, the existing approach
"creates a namespace minefield for programmers".

Functions should be classified into a heirarchcal tree, with
the braches of the tree represented by components in the fuction
names.

Creating a function taxonomy where everything comes directly off
the root creates a classification disaster - where nobody can find
anything - functions are not logically grouped - any anyone writing
their own function has to watch where they are stepping.

Consider what happens when a new version of PHP comes out with a
whole bunch of new fuctions - if they are in a big global namespace
and are free to clash with everyone else's fuctions.
many new functions need to be created as member function of the
appropriate objects - and most of the old functions in the global
namespace need deprecating.


Why? If you want to have objects all over use Java.


But Java is proprietary code - under a commerical license, and has
less server-side penetration that PHP, limiting the customer base.
PHP allows you to write code with OOP or without, whatever you like.


/With/, please - and /without/ the standard library dragging
everything into the procedural gutter, please.
Does anyone think the existing mess will ever get cleaned up?

Or is PHP's function namespace too shafted at this stage to
ever be repaired?


I have no problem with it (only little problem I have are the different
styles in function names, fooBar() vs. foo_bar()).


Yes - an even more embarassing mess ;-)
--
__________
|im |yler http://timtyler.org/ ti*@tt1lock.org Remove lock to reply.
Jul 17 '05 #8
Tony Marston <to**@nospam.de mon.co.uk> wrote or quoted:
I think you're talking crap. Just because other languages have namespaces
does not mean that PHP *must* have them as well.
PHP *already* has objects - which are good enough as namespaces for many
purposes.

What it doesn't have is a standard library that takes proper advantage
of its OO features.
I get pretty cheesed off when some geek says "I'm trying to learn PHP after
using language X, but I am finding it difficult because PHP does things
differently. Why can't it be more like X?"

I have groundbreaking news for all you geeks - PHP is not the same as
language X because IT IS DIFFERENT. If it was the same then there would be
no point. Different languages are different, so get used to the differences
and STOP COMPLAINING.


I'm pointing out a serious problem with PHP.

PHP should *benefit* from people pointing out its deficiencies.

If nobody complains, the designers get no feedback about where they
have screwed up the worst. They lack the information they need to
improve their product - and future architects wind up copying the
mistakes of existing systems, for the sake of factors like familiarity.
--
__________
|im |yler http://timtyler.org/ ti*@tt1lock.org Remove lock to reply.
Jul 17 '05 #9
Alvaro G. Vicario <kA************ *****@terra.es> wrote or quoted:
I'm not sure of what the original poster meant. Should we replace...

$a=trim($b);

... with...

$aux=new StringFunctions ();
$a=$aux->trim($b);
:-?


The conventional approach would be:

$a = $b -> trim();
--
__________
|im |yler http://timtyler.org/ ti*@tt1lock.org Remove lock to reply.
Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
7509
by: Tony Johansson | last post by:
Hello! I'm reading a book about C++ and there is something that I don't understand so I ask you. Below I have the text from the book and the code from the file where main is located and some namespace definition with class definitions. The book says "C++ has a global anonymous namespace that is similar to Java's global anonymous package. All declarations not explicitly placed in named
1
29366
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have called it polluting the global namespace. This article explores what happens when the global namespace becomes polluted and how to avoid this condition. The opinions expressed in this article are those of the author alone although many have...
0
8749
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9109
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8956
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7853
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5922
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2434
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2057
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.