Avoid legacy programming practices in PHP 5.4: the underscore lesson from PHP4/5
Join the DZone community and get the full member experience.Join For Free
Old habits die hard; old language habits die harder; old programming habits die hardest, especially when the habit first developed from a defect in the language.
So as PHP5.4 approaches, it's a good idea to take stock of the habits you may have developed in previous versions of PHP.
Volker Dusch addresses one of these habits: the 'privatizing underscore', an old dodge designed to keep variables private in the programmer's head -- because PHP4 couldn't keep variables private on its own.
PHP 5 offeredprivate variables, so nobody really needed underscores anymore. But plenty of apps were still written in PHP4; and, besides, lots of coders were used to those underscores, so they kept on using them anyway.
But now PHP4 has mostly disappeared. It's to act like it's gone, declares Volker:
We are deep into 5.x now and it’s time to get rid of your PHP 4 legacy. The last release was 3 years ago, the number of people that still admit to using it in production dropped below the care ratio and all major frameworks and libs migrated.
The real point is that retaining legacy programming practices past due date can only lead to rotten code. (For example, what if you need to make a variable public? 'Replace all in project'?)
advice is: every new language release is an opportunity to move on. But,
more specifically, stop talking in underscores to PHP4 users that no
Read the rest of his post here.
Opinions expressed by DZone contributors are their own.