<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Function Overloading and PHP</title>
	<atom:link href="http://blog.stevedoria.net/20050803/function-overloading-and-php/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.stevedoria.net/20050803/function-overloading-and-php</link>
	<description>Real-World Computing Experience Distilled</description>
	<lastBuildDate>Wed, 18 Aug 2010 02:35:04 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Marco Schuster</title>
		<link>http://blog.stevedoria.net/20050803/function-overloading-and-php/comment-page-1#comment-7738</link>
		<dc:creator>Marco Schuster</dc:creator>
		<pubDate>Mon, 31 May 2010 23:53:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevedoria.net/?p=3#comment-7738</guid>
		<description>Link again: http://de3.php.net/manual/en/function.func-get-args.php</description>
		<content:encoded><![CDATA[<p>Link again: <a href="http://de3.php.net/manual/en/function.func-get-args.php" rel="nofollow">http://de3.php.net/manual/en/function.func-get-args.php</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marco Schuster</title>
		<link>http://blog.stevedoria.net/20050803/function-overloading-and-php/comment-page-1#comment-7737</link>
		<dc:creator>Marco Schuster</dc:creator>
		<pubDate>Mon, 31 May 2010 23:52:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevedoria.net/?p=3#comment-7737</guid>
		<description>You can do this with , even if it&#039;s not proper overloading.

Peace,
Marco</description>
		<content:encoded><![CDATA[<p>You can do this with , even if it&#8217;s not proper overloading.</p>
<p>Peace,<br />
Marco</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tanvir</title>
		<link>http://blog.stevedoria.net/20050803/function-overloading-and-php/comment-page-1#comment-7731</link>
		<dc:creator>Tanvir</dc:creator>
		<pubDate>Sat, 15 May 2010 18:46:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevedoria.net/?p=3#comment-7731</guid>
		<description>Hello
I have shown a good example in my blog ( http://blog.actcode.com/2010/05/php-overloading-method-overloading-and.html ).
It&#039;s clearly described there , that how overloading should implement.

Thnaks
Tanvir.</description>
		<content:encoded><![CDATA[<p>Hello<br />
I have shown a good example in my blog ( <a href="http://blog.actcode.com/2010/05/php-overloading-method-overloading-and.html" rel="nofollow">http://blog.actcode.com/2010/05/php-overloading-method-overloading-and.html</a> ).<br />
It&#8217;s clearly described there , that how overloading should implement.</p>
<p>Thnaks<br />
Tanvir.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: maximus</title>
		<link>http://blog.stevedoria.net/20050803/function-overloading-and-php/comment-page-1#comment-7710</link>
		<dc:creator>maximus</dc:creator>
		<pubDate>Sun, 07 Mar 2010 22:18:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevedoria.net/?p=3#comment-7710</guid>
		<description>Some of the replies to this article are another example displaying that PHP harvests the scum of the programming world. A community full of know-it-all ignorants, that never seize the chance they&#039;re given to shut up and learn something new. For all the convenience the language offers, other aspiring programmers, who truly want to get better at their craft, have to put up with this nonsense. 

I&#039;m sorry I had to get it out of my chest.

Now, offering something constructive that hopefully highlights a bit more why the current language&#039;s overloading facility lacks.

Sound software engineering principles will tell you &quot;code to an interface, not an implementation&quot;. Therefore if you want to create a generic Validator signature, you could just do something like this.

Interface Validator {
	function setValues($values);
	function isValid($values);
	function isValid();
}

This specifies that the validator object can optionally receive data in its isValid method, but it&#039;s not mandatory (maybe you&#039;ve already set data previously with setValues()). 

With this signature, you&#039;re not forced to separately call setValid() and isValid(), but you&#039;re not forced either to have an isValid method that absolutely requires to take in a parameter. Unfortunately due to PHP&#039;s lack of true method overloading, you can&#039;t define such an interface.

I can see people coming a mile away with stuff like

function isValid($array = null);

Wrong! Interface, remember? You should specify if the function takes a parameter or not.

The hacking spirit, rampant in PHP has had people used to McGyverish code where, instead of just directly working toward its primary goal, a function has to check the state of its parameters.

Lets say your interface define the signature as:

function isValid($array);

and that you implement as:

function isValid($array=null)
	if($array){
		$this-&gt;setValue($array);
	}
	$this-&gt;validate();
}

Even if you do this, you still won&#039;t be able to call your method like

$myValidator-&gt;isValid();

because the Interface requires that isValid takes a parameter. You will be forced to do:

$myValidator-&gt;isValid(null);

Tell me this isn&#039;t ugly.</description>
		<content:encoded><![CDATA[<p>Some of the replies to this article are another example displaying that PHP harvests the scum of the programming world. A community full of know-it-all ignorants, that never seize the chance they&#8217;re given to shut up and learn something new. For all the convenience the language offers, other aspiring programmers, who truly want to get better at their craft, have to put up with this nonsense. </p>
<p>I&#8217;m sorry I had to get it out of my chest.</p>
<p>Now, offering something constructive that hopefully highlights a bit more why the current language&#8217;s overloading facility lacks.</p>
<p>Sound software engineering principles will tell you &#8220;code to an interface, not an implementation&#8221;. Therefore if you want to create a generic Validator signature, you could just do something like this.</p>
<p>Interface Validator {<br />
	function setValues($values);<br />
	function isValid($values);<br />
	function isValid();<br />
}</p>
<p>This specifies that the validator object can optionally receive data in its isValid method, but it&#8217;s not mandatory (maybe you&#8217;ve already set data previously with setValues()). </p>
<p>With this signature, you&#8217;re not forced to separately call setValid() and isValid(), but you&#8217;re not forced either to have an isValid method that absolutely requires to take in a parameter. Unfortunately due to PHP&#8217;s lack of true method overloading, you can&#8217;t define such an interface.</p>
<p>I can see people coming a mile away with stuff like</p>
<p>function isValid($array = null);</p>
<p>Wrong! Interface, remember? You should specify if the function takes a parameter or not.</p>
<p>The hacking spirit, rampant in PHP has had people used to McGyverish code where, instead of just directly working toward its primary goal, a function has to check the state of its parameters.</p>
<p>Lets say your interface define the signature as:</p>
<p>function isValid($array);</p>
<p>and that you implement as:</p>
<p>function isValid($array=null)<br />
	if($array){<br />
		$this-&gt;setValue($array);<br />
	}<br />
	$this-&gt;validate();<br />
}</p>
<p>Even if you do this, you still won&#8217;t be able to call your method like</p>
<p>$myValidator-&gt;isValid();</p>
<p>because the Interface requires that isValid takes a parameter. You will be forced to do:</p>
<p>$myValidator-&gt;isValid(null);</p>
<p>Tell me this isn&#8217;t ugly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Edgarin</title>
		<link>http://blog.stevedoria.net/20050803/function-overloading-and-php/comment-page-1#comment-7706</link>
		<dc:creator>Edgarin</dc:creator>
		<pubDate>Tue, 16 Feb 2010 07:17:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevedoria.net/?p=3#comment-7706</guid>
		<description>Although function/method overloading can be &quot;emulated&quot; in the case we want different behavior for different parameter data types or number of parameters; don&#039;t forget there are many other cases where we need method overloading that can&#039;t be emulated, for example:

(This code doesn&#039;t compile, of course)
class AClass{
    var $member;
    static function myMethod() { echo &quot;Static&quot;; }
    function myMethod() { echo $this-&gt;member; }
}
AClass::myMethod(); //Should display &quot;Static&quot;;
$obj = new AClass();
$obj-&gt;myMethod();  //Should display contents of $member

Unfortunately, in this example, there is no other way than renaming one (or both) methods.</description>
		<content:encoded><![CDATA[<p>Although function/method overloading can be &#8220;emulated&#8221; in the case we want different behavior for different parameter data types or number of parameters; don&#8217;t forget there are many other cases where we need method overloading that can&#8217;t be emulated, for example:</p>
<p>(This code doesn&#8217;t compile, of course)<br />
class AClass{<br />
    var $member;<br />
    static function myMethod() { echo &#8220;Static&#8221;; }<br />
    function myMethod() { echo $this-&gt;member; }<br />
}<br />
AClass::myMethod(); //Should display &#8220;Static&#8221;;<br />
$obj = new AClass();<br />
$obj-&gt;myMethod();  //Should display contents of $member</p>
<p>Unfortunately, in this example, there is no other way than renaming one (or both) methods.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gregx</title>
		<link>http://blog.stevedoria.net/20050803/function-overloading-and-php/comment-page-1#comment-7677</link>
		<dc:creator>gregx</dc:creator>
		<pubDate>Thu, 10 Dec 2009 15:20:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevedoria.net/?p=3#comment-7677</guid>
		<description>it is funny, i just started to look and learn php about 1/2 years ago and was googling about the same issue and got here. I wouldn&#039;t say anything bad about the article but it seems to me some comments are made by people who are never used any other language besides php. This is disgrace! Probably that&#039;s why all those php sites lack security so often because they are made by narrowminded lazy programmers! 

PS. started 25 years ago in asm</description>
		<content:encoded><![CDATA[<p>it is funny, i just started to look and learn php about 1/2 years ago and was googling about the same issue and got here. I wouldn&#8217;t say anything bad about the article but it seems to me some comments are made by people who are never used any other language besides php. This is disgrace! Probably that&#8217;s why all those php sites lack security so often because they are made by narrowminded lazy programmers! </p>
<p>PS. started 25 years ago in asm</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Drizd</title>
		<link>http://blog.stevedoria.net/20050803/function-overloading-and-php/comment-page-1#comment-7634</link>
		<dc:creator>Drizd</dc:creator>
		<pubDate>Fri, 11 Sep 2009 11:28:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevedoria.net/?p=3#comment-7634</guid>
		<description>I agree, not a good article, but it does touch on the important - PHP&#039;s inability to stand with other &quot;proper&quot; object oriented languages have made me dump it in favour of other technologies for numerous projects.</description>
		<content:encoded><![CDATA[<p>I agree, not a good article, but it does touch on the important &#8211; PHP&#8217;s inability to stand with other &#8220;proper&#8221; object oriented languages have made me dump it in favour of other technologies for numerous projects.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: julesmanson</title>
		<link>http://blog.stevedoria.net/20050803/function-overloading-and-php/comment-page-1#comment-7609</link>
		<dc:creator>julesmanson</dc:creator>
		<pubDate>Thu, 30 Jul 2009 18:23:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevedoria.net/?p=3#comment-7609</guid>
		<description>I agree with steve doria of this site however I would take my own magic overload function one step further and have it automatically load as soon as the php/mysql software is up and running on the server instead of invoked from a class object defined on some page and loaded with __autoload. Now that&#039;s real magic for ya. I am sure there is a way via config.php or .htacccess but I just don&#039;t know how to do that yet. Perhaps someone can point me in the right direction. Thanks.</description>
		<content:encoded><![CDATA[<p>I agree with steve doria of this site however I would take my own magic overload function one step further and have it automatically load as soon as the php/mysql software is up and running on the server instead of invoked from a class object defined on some page and loaded with __autoload. Now that&#8217;s real magic for ya. I am sure there is a way via config.php or .htacccess but I just don&#8217;t know how to do that yet. Perhaps someone can point me in the right direction. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mmm</title>
		<link>http://blog.stevedoria.net/20050803/function-overloading-and-php/comment-page-1#comment-7607</link>
		<dc:creator>mmm</dc:creator>
		<pubDate>Wed, 29 Jul 2009 05:57:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevedoria.net/?p=3#comment-7607</guid>
		<description>mmmmmmm</description>
		<content:encoded><![CDATA[<p>mmmmmmm</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: seems</title>
		<link>http://blog.stevedoria.net/20050803/function-overloading-and-php/comment-page-1#comment-7606</link>
		<dc:creator>seems</dc:creator>
		<pubDate>Sun, 26 Jul 2009 20:32:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevedoria.net/?p=3#comment-7606</guid>
		<description>Actually Mr bearman, you re very wrong. trying to be smart in your response you have only appeared as shallow as one can be. &quot;You fail&quot; very clearly, accurately and precisely defines the content of this post. It is extremely useful to read his post before any other on this page because it contributes in the decrease of waste of time to humanity. Your post Mr bearman is even more obnoxious than the piece of junk of an article itself.</description>
		<content:encoded><![CDATA[<p>Actually Mr bearman, you re very wrong. trying to be smart in your response you have only appeared as shallow as one can be. &#8220;You fail&#8221; very clearly, accurately and precisely defines the content of this post. It is extremely useful to read his post before any other on this page because it contributes in the decrease of waste of time to humanity. Your post Mr bearman is even more obnoxious than the piece of junk of an article itself.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
