 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Typical Programmer Blog: Doing it wrong getters and setters
by Chris Cornutt June 16, 2008 @ 11:19:17
According to this new post on the Typical Programmer blog, using getters and setters in your scripts only adds in a bit of unnecessary coupling and complexity to your scripts that you just don't need.
Today most of the popular programming languages support objects, limiting scope, modularity, passing by value, and sophisticated built-in types. There should be no reason to deliberately expose an object's data to the rest of the code because the language can enforce encapsulation and data hiding.
While not specific to PHP, the post does recommend against them because of one simple reason common to all languages that make them possible - they "break the encapsulation OOP offers". For them, they're like a cheat to get around bad coding practices and are not needed to make a successful application work.
voice your opinion now!
getter setter break object oriented encapsulation scope bad
SitePoint PHP Blog: Lexical scope to appear in PHP?
by Chris Cornutt December 25, 2007 @ 09:46:00
<>
In this new post to the SitePoint PHP blog, Troels Knak-Nielsen talks about some of the advancements (and diagreements) that have happened around adding lexical scope to the create_function functionality.
The main argument against approving the patch, seems to be, that one would expect static scoping rules to apply to the anonymous function. After all, this is the case in similar languages, which support anonymous functions. One could only assume, that changing PHP to support this, would be a major undertaking.
One would be wrong, it seems.
A patch has been made to add the functionality (from Christian Seller) adding a new keyword, lexical, to make it all work.
voice your opinion now!
lexical patch scope parse christianseller lexical patch scope parse christianseller
Arnold Daniels' Blog: Perl like temporary variables in PHP
by Chris Cornutt November 02, 2007 @ 09:38:00
Arnold Daniels points out a quick method for creating what he calls "perl-like temporary variables" in the global scope of a script:
When writing code in the global scope, I often have a problem where I'm overwriting a variable. This happens even more often when I work on code of somebody else. Usually has the variable which does the overwriting is usually just a temporary variable.
His code is a simple few lines that shows how it could be used when trying to write information out to a file handle. Some of the comments on the post criticize his use of the global scope but Arnold comes back with his reasoning - mostly that there is already code in the global scope and that adding something else is only adding to it, not making things worse.
voice your opinion now!
temporary variable perl global scope temporary variable perl global scope
PHP 10.0 Blog: More inlining
by Chris Cornutt November 20, 2006 @ 08:10:00
On the PHP 10.0 Blog, Stas talks more about inlining in PHP functions - some of the bad things this time (see here and here for other comments), including things that could break an application if not handled correctly.
Performance benefits from inlining simple functions might be significant, since function call in PHP is not cheap. We'd have some potential problems there.
Included in the list are things like:
- Variable scoping - we don't want function variables to mess with our scope, so we'd probably rename them or something.
- Then we might get a problem if function messing with current scope is called indirectly so we can't really know.
- And then some may use end-of-scope for destruction of variables that have dtors, so when we'd clean up these variables?
voice your opinion now!
inlining function performance benefit problem scope variable inlining function performance benefit problem scope variable
Tnx.nl: PHP in Contrast to Perl
by Chris Cornutt May 22, 2006 @ 06:21:33
As long as people "choose sides" when it comes to programming languages, there will always be articles like this to compare them. This time, it's a look at PHP versus another much-loved language, Perl.
The article takes a look at several different topics under this one umbrella, including:
- Arguments and return values are extremely inconsistent
- PHP has inconsistent function naming
- PHP has no lexical scope
- PHP has too many functions in the core
Obviously, they all seem to take a negative slant on PHP, but they do provide some content under each of the headings to back up their claims. They break out the contents of each of these examples to make comparison of Perl's and PHP's similar functionality easier. At the end, they also provide links to other resources and other posters illustrating some of the points they've shown.
voice your opinion now!
php contrast perl arguments function naming scope php contrast perl arguments function naming scope
|
Community Events
Don't see your event here? Let us know!
|