News Feed
Sections
News Archive


Community Events






feed this:

Derick Rethans' Blog:
Namespaces in PHP
0 comments :: posted Monday June 16, 2008 @ 07:54:39
voice your opinion now!

After hearing Stefan Priebsch's talk at this year's Dutch PHP Conference, something occurred to Derick Rethans - there was a small sort of issue with using namespaces and possible future PHP's own namespace.

One of the things that came up is the conflicts that can arise with internal classes. In PHP 5.3 this would alias the class Interval in the namespace PEAR::Date to the class Interval. For now, this code would work just fine. However, if PHP would introduce a class "Interval" at some point in the future (and PHP can do this as it owns the global namespace) then the above code would suddenly stop working

He offers a simple solution that can prevent this sort of conflict for the future - defining your "use" and then creating a new instance of the namespace into a variable instead of just an "as".

tagged with: namespace problem global implement future use conflict


Stoyan Stefanov's Blog:
PHP-style $GLOBALS in Javascript?
7 comments :: posted Wednesday March 12, 2008 @ 07:55:07
voice your opinion now!

In a new post to his blog today, Stoyan Stefanov has a proposal to being something PHP users are very used to - superglobals - over to Javascript.

Javascript has implied globals. When you skip the var in var a = 1; and go a = 1;, then a becomes a global variable. Some consider this an error in the language. [...] In PHP on the other hand, variables are local. [...] So how about this: adopt the $GLOBALS convention in your JavaScripts?

His example proposes the creation of a GLOBALS object you can assign properties to that can be used anywhere. This helps to keep the variables you truely want to be global contained, though it doesn't do much except provide a convention.

tagged with: superglobal global variable javascript

SitePoint PHP Blog:
What's so bad about the Singleton?
0 comments :: posted Wednesday February 13, 2008 @ 12:13:00
voice your opinion now!

On the SitePoint PHP Blog today Troels Knak-Nielsen asks th3e question "what's so bad about the singleton?" For all of its advantages, is there a darker side of the design pattern when it pertains to global variables.

As I have often taken this stance myself, I found it reasonable that I should be able to argue for it, so I'll try to give an explanation. This is also in part a follow-up on my post from last week, in which I present a way to avoid global symbols, without spending much time on why.

He talks about what they are and how they're commonly used - sometimes with some unpleasant side effects because of their use of globals.

tagged with: singleton designpattern global sideeffect static

Soledad Penades' Blog:
Signs your PHP needs refactoring
0 comments :: posted Tuesday June 05, 2007 @ 16:26:00
voice your opinion now!

As mentioned by Ed Finkler, there's a list of signs your PHP needs refactoring from Soledad Penades.

I have had to go through a php application recently which has given me more than one headache and has required me to use all my possible patience. While working with it, I thought This is good material for an article, so that nobody else does the same in the future, and nobody else will need to experience the same displeasure as I have had to.

So here are the signs your PHP application needs a serious refactoring, right now

Included in the list are things like:

  • Uses global variables
  • Everything's an array
  • The neverending switch
  • Interface inconsistency

It hits on one of the thing that bugs me too, the problem of "Brackets galore" - so many subarrays that you have to resort to three or more sets of bracketed keys to get to the value you want. It's bad enough trying to follow someone else's code without having to "trace down" an array to figure out which of the values they're talking about.

tagged with: refactoring global bracket duplicate switch interface inconsistent refactoring global bracket duplicate switch interface inconsistent


release framework zendframework code developer zend database PHP5 book conference ajax PEAR pecl application cakephp mysql package releases job security

All content copyright, 2008 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework