<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Fri, 08 Aug 2008 16:18:13 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Debuggable Blog: Programming Psychology II: Private methods ]]></title>
      <guid>http://www.phpdeveloper.org/news/10560</guid>
      <link>http://www.phpdeveloper.org/news/10560</link>
      <description><![CDATA[<p>
According to <i>Felix Geisendorfer</i>'s <a href="http://www.debuggable.com/posts/programming-psychology-ii-private-methods:481ed862-b0d8-4a0e-9247-165c4834cda3">newest post</a> on the Debuggable blog, he thinks that "private and protected methods and properties are one of the most stupid concepts of OOP."
</p>
<blockquote>
This is a thought I first shared at <a href="http://debuggable.com/posts/cakefest-orlando-2008-summary:480f4dd6-6404-4774-a771-4e8fcbdd56cb">CakeFest Orlando</a> this year, but could not explain properly at the time.
</blockquote>
<p>
He illustrates with an example of a protected "balance" variable in a BankAccount class. Sure, it's marked as private but less skilled programmers might not use it that way. He recommends a method without the getters/setters to help make the usage of the variable a bit simpler. He also suggests that using protected/private scoping helps to promote "crappy code" - using them to provide a sort of protection for code that you either don't want getting used or hiding it away so the API can't get at it.
</p>]]></description>
      <pubDate>Tue, 08 Jul 2008 08:44:58 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[DevShed: More on Private Methods with PHP 5 Member Visibility ]]></title>
      <guid>http://www.phpdeveloper.org/news/10486</guid>
      <link>http://www.phpdeveloper.org/news/10486</link>
      <description><![CDATA[<p>
DevShed finishes off their series looking a private, public and protected variables and methods in classes with <a href="http://www.devshed.com/c/a/PHP/More-on-Private-Methods-with-PHP-5-Member-Visibility/">this final look</a> a private methods in PHP5 object-oriented programming.
</p>
<blockquote>
It's time to leap forward and tackle this final article of the series, which will be focused on covering some additional aspects concerning the use of this kind of class method. In addition, I'll teach you how to utilize the "final" keyword, which is included with PHP 5, to prevent the methods of a specific class from being overridden by any subclass.
</blockquote>
<p>
They work from a <a href="http://www.devshed.com/c/a/PHP/More-on-Private-Methods-with-PHP-5-Member-Visibility/1/">hands-on example</a> to show how they can work with private methods (expanding a bit from last time) and how to use the "final" keyword to restrict any and all modification for a method.
</p>]]></description>
      <pubDate>Wed, 25 Jun 2008 13:58:20 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[DevShed: Utilizing Private Methods with PHP 5 and Member Visibility ]]></title>
      <guid>http://www.phpdeveloper.org/news/10437</guid>
      <link>http://www.phpdeveloper.org/news/10437</link>
      <description><![CDATA[<p>
DevShed has posted the <a href="http://www.devshed.com/c/a/PHP/Utilizing-Private-Methods-with-PHP-5-and-Member-Visibility/">fifth part</a> of their series looking at the visibility keywords on PHP5's object oriented support today. They've already looked at <a href="http://www.phpdeveloper.org/news/10292">private</a>, <a href="http://www.phpdeveloper.org/news/10394">public</a> and <a href="http://www.phpdeveloper.org/news/10292">protected</a> properties in a class, now they look at the use of making methods private to restrict their use/extension.
</p>
<blockquote>
Of course, when it comes to specifying how visible a certain class property or method will be, you know that PHP 5 permits you to work with three distinct levels of access, called "public," "protected," and "private" respectively. [...] As you may have noticed, however, I've not taught you how to define private methods yet, which is something that can definitely be very useful if you want to restrict the access to your classes from the outside more severely.
</blockquote>
<p>
The <a href="http://www.devshed.com/c/a/PHP/Utilizing-Private-Methods-with-PHP-5-and-Member-Visibility/">tutorial</a> shows the creation of a class with private properties and then expands it to include a private method. Then they call it from an object, an example of the error PHP kicks back is there too. He also includes the concept of a "getter" to call the private function from a public one.
</p>]]></description>
      <pubDate>Thu, 19 Jun 2008 07:58:51 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Michael Kimsal's Blog: PHP, Groovy and language evolution]]></title>
      <guid>http://www.phpdeveloper.org/news/10298</guid>
      <link>http://www.phpdeveloper.org/news/10298</link>
      <description><![CDATA[<p>
In a <a href="http://michaelkimsal.com/blog/php-groovy-and-language-evolution/">new post</a> <i>Michael Kimsal</i> does a good job comparing the rise of PHP5 (and what it brought with it) to his language of choice these days - <a href="http://groovy.codehaus.org/">Groovy</a>.
</p>
<blockquote>
I remember when PHP5 first came out having 'discussions' with a number of people who insisted that PHP5 was way better than 4. [...] Basically, intentions were made clearer with things like "public protected private" (PPP),but I have not yet seen any web project get done faster or dare I say even much *better* due to those sorts of things. [...] This isn't specifically saying PPP is necessarily bad, but that PHP could have addressed the issue in a fashion more suitable to dynamic languages.  Keep reading for an example.
</blockquote>
<p>
His comparison is to how Groovy handles properties in a class - everything is private unless declared otherwise. This could be ported (somewhat) over to PHP and would eliminate the need to search&replace all over the code for the right variables.
</p>]]></description>
      <pubDate>Thu, 29 May 2008 12:52:07 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[DevShed: Working with Private Properties to Protect PHP 5 Class Data]]></title>
      <guid>http://www.phpdeveloper.org/news/10292</guid>
      <link>http://www.phpdeveloper.org/news/10292</link>
      <description><![CDATA[<p>
DevShed continues their look at the use of the member visibility functionality PHP5 offers in its classes with <a href="http://www.devshed.com/c/a/PHP/Working-with-Private-Properties-to-Protect-PHP-5-Class-Data/">this new part</a> of the series, a look at the private property.
</p>
<blockquote>
One of the most useful features that was introduced into the improved object model of PHP 5 is "member visibility." It provides PHP developers with the ability to specify the level of access each data member of a class will have in the context of a given application.
</blockquote>
<p>
They <a href="http://www.devshed.com/c/a/PHP/Working-with-Private-Properties-to-Protect-PHP-5-Class-Data/1/">review</a> the other two keywords (public/protected) before venturing on to the <a href="http://www.devshed.com/c/a/PHP/Working-with-Private-Properties-to-Protect-PHP-5-Class-Data/2/">use of "private"</a> to protect, but allow access to, methods and properties in a parent class.
</p>]]></description>
      <pubDate>Thu, 29 May 2008 08:47:04 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[DevShed: Protecting PHP 5 Class Data with Member Visibility]]></title>
      <guid>http://www.phpdeveloper.org/news/10244</guid>
      <link>http://www.phpdeveloper.org/news/10244</link>
      <description><![CDATA[<p>
In <a href="http://www.devshed.com/c/a/PHP/Protecting-PHP-5-Class-Data-with-Member-Visibility/">this new tutorial</a> posted to DevShed, they take a look at working with classes in PHP5, specifically using the keywords for "member visibility" to make your classes a bit more structured.
</p>
<blockquote>
The previous concept can also be applied successfully when it comes to defining the visibility of properties and methods in PHP classes. [...] Using the jargon of object-oriented programming, this capacity is widely known as member visibility. This capacity allows PHP programmers to establish whether the set of methods and properties of a specific class will be public, protected, or private.
</blockquote>
<p>
They start more generally by looking at how to set up the variables <a href="http://www.devshed.com/c/a/PHP/Protecting-PHP-5-Class-Data-with-Member-Visibility/1/">globally</a> and then move down the line talking about <a href="http://www.devshed.com/c/a/PHP/Protecting-PHP-5-Class-Data-with-Member-Visibility/2/">restrictions</a> (private/protected/public) and how to <a href="http://www.devshed.com/c/a/PHP/Protecting-PHP-5-Class-Data-with-Member-Visibility/3/">get to them</a> in the scripts outside the class.
</p>]]></description>
      <pubDate>Thu, 22 May 2008 09:37:05 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHP in Action: Public constructors considered harmful]]></title>
      <guid>http://www.phpdeveloper.org/news/10109</guid>
      <link>http://www.phpdeveloper.org/news/10109</link>
      <description><![CDATA[<p>
According to the PHP in Action blog, public constructors can be <a href="http://www.reiersol.com/blog/index.php?op=ViewArticle&articleId=34&blogId=1">hazardous to your (application's) health</a> and should be replaced.
</p>
<blockquote>
Everybody who writes object-oriented code knows about constructors. You need them so the program knows how to instantiate objects, right? And you especially need them when a lot of things have to be done while instantiating an object. [...] So why would I be skeptical of public constructors?
</blockquote>
<p>
The solution, as <a href="http://www.reiersol.com/blog/index.php?op=ViewArticle&articleId=34&blogId=1">he sees it</a>, is to make a "constructor" that's actually called statically with parameters that returns an instance of the class it's in as well as performing the action. He argues that this can help make the code much more readable for some types of method calls.
</p>]]></description>
      <pubDate>Mon, 05 May 2008 10:21:33 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPBuilder.com: Class Inheritance with PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/9648</guid>
      <link>http://www.phpdeveloper.org/news/9648</link>
      <description><![CDATA[<p>
On PHPBuilder.com today, there's <a href="http://www.phpbuilder.com/columns/kris_hadlock20080215.php3">a new tutorial</a> that takes a beginning look at PHP5's class inheritance model.
</p>
<blockquote>
There are many benefits of inheritance with PHP, the most common is simplifying and reducing instances of redundant code. Class inheritance may sound complicated, but think of it this way. Consider a tree. A tree is made up of many parts, such as the roots that reside in the ground, the trunk, bark, branches, leaves, etc. Essentially inheritance is a connection between a child and its parent.
</blockquote>
<p>
They choose to go with a "car" illustration instead and <a href="http://www.phpbuilder.com/columns/kris_hadlock20080215.php3">show how</a> a child of the Product class (Car) can access the private properties of the parent. They also include an example of it in action with a bit of HTML output.
</p>]]></description>
      <pubDate>Mon, 18 Feb 2008 07:58:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Tobias Schlitt's Blog: Reflecting private properties]]></title>
      <guid>http://www.phpdeveloper.org/news/9645</guid>
      <link>http://www.phpdeveloper.org/news/9645</link>
      <description><![CDATA[<p>
<i>Tobias Schlitt</i> has <a href="http://schlitt.info/applications/blog/index.php?/archives/581-Reflecting-private-properties.html">posted a handy tip</a> about using the Reflection API in PHP5 - specifically its accessing of private properties in a class.
</p>
<blockquote>
I recently stumbled over reflecting private properties in PHP again. As you might know, this was not possible until now and if you tried this [code] PHP thanked it to you with this [error that is cannot access a non-public member].
</blockquote>
<p>
He notes that, while the <a href="http://schlitt.info/applications/blog/index.php?/archives/581-Reflecting-private-properties.html">behaviour is correct</a>, it still makes things like <a href="http://schlitt.info/applications/blog/exit.php?url_id=4456&entry_id=581">metaprogramming</a> impossible. So, what's a developer to do? Patch it of course! <i>Tobias</i> and <i>Derick Rethans</i> persuaded two other developers  (<i>Derick</i> and <i>Marcus Borger</i>) to include a patch that allows the Reflection API to see these private variables.
</p>
<p>
To make it work, you have to use the setAccessible method on the Reflection object to set which of the properties you want to be able to get at.
</p>]]></description>
      <pubDate>Fri, 15 Feb 2008 12:02:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Stefan Mischook's Blog: A Question about object properties in PHP Classes]]></title>
      <guid>http://www.phpdeveloper.org/news/9199</guid>
      <link>http://www.phpdeveloper.org/news/9199</link>
      <description><![CDATA[<p>
<i>Stefan Mischook</i> shares a little <a href="http://www.killerphp.com/articles/object-properties/">question and answer</a> he had recently concerning object properties in PHP.
</p>
<p>
The question asked about accessing properties outside the class and/or defining them as protected/private to prevent it. <i>Stefan</i>'s response was basically:
</p>
<blockquote>
Many OO techniques are designed for situations where you will have more than one programmer involved, now or later. By declaring variables as protected or private, you are adding security to the code base by forcing the use of getter and setter methods where you can control how objects are used.
</blockquote>]]></description>
      <pubDate>Fri, 07 Dec 2007 14:33:00 -0600</pubDate>
    </item>
  </channel>
</rss>
