<?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: Type hints are more useful for scalars than objects</title>
	<atom:link href="http://blog.agilephp.com/2008/09/07/type-hints-are-more-useful-for-scalars-than-objects/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.agilephp.com/2008/09/07/type-hints-are-more-useful-for-scalars-than-objects/</link>
	<description>Dagfinn Reiersøl on PHP, agile development, Ruby and other addictive substances</description>
	<lastBuildDate>Thu, 11 Mar 2010 18:16:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Mike</title>
		<link>http://blog.agilephp.com/2008/09/07/type-hints-are-more-useful-for-scalars-than-objects/comment-page-1/#comment-89</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Fri, 12 Sep 2008 09:10:14 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/wordpress/?p=1417#comment-89</guid>
		<description>&lt;p&gt;One thing that (PHP-)developers tend to miss is that OOP is a lot about describing and strictly defining your architecture or class or function and not just about &quot;let&#039;s pack some functions into a file and call it a class&quot;.  &lt;/p&gt;
&lt;p&gt;With a strictly defined code, you are able to just read and understand another developer&#039;s piece of code simply by looking at it. The other developer could also be you, revisiting your own code after months, weeks or just days.&lt;/p&gt;
&lt;p&gt;And, more importantly, you can&#039;t break anything all too easily.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>One thing that (PHP-)developers tend to miss is that OOP is a lot about describing and strictly defining your architecture or class or function and not just about &#8220;let&#8217;s pack some functions into a file and call it a class&#8221;.  </p>
<p>With a strictly defined code, you are able to just read and understand another developer&#8217;s piece of code simply by looking at it. The other developer could also be you, revisiting your own code after months, weeks or just days.</p>
<p>And, more importantly, you can&#8217;t break anything all too easily.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alan Pinstein</title>
		<link>http://blog.agilephp.com/2008/09/07/type-hints-are-more-useful-for-scalars-than-objects/comment-page-1/#comment-88</link>
		<dc:creator>Alan Pinstein</dc:creator>
		<pubDate>Thu, 11 Sep 2008 22:00:44 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/wordpress/?p=1417#comment-88</guid>
		<description>&lt;p&gt;I was excited about type hinting when it first came out, but quickly abandoned using it.&lt;/p&gt;
&lt;p&gt;The main problem I ran into was that you get a FATAL error if your argument doesn&#039;t match. This causes problems for applications that have highly dynamic runtimes and may at times generate the wrong objects. You can&#039;t easily catch the error since it&#039;s FATAL.&lt;/p&gt;
&lt;p&gt;Instead, I do asserts at the top of my functions that throw exceptions if the improper data is passed.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>I was excited about type hinting when it first came out, but quickly abandoned using it.</p>
<p>The main problem I ran into was that you get a FATAL error if your argument doesn&#8217;t match. This causes problems for applications that have highly dynamic runtimes and may at times generate the wrong objects. You can&#8217;t easily catch the error since it&#8217;s FATAL.</p>
<p>Instead, I do asserts at the top of my functions that throw exceptions if the improper data is passed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dagfinn</title>
		<link>http://blog.agilephp.com/2008/09/07/type-hints-are-more-useful-for-scalars-than-objects/comment-page-1/#comment-87</link>
		<dc:creator>dagfinn</dc:creator>
		<pubDate>Sun, 07 Sep 2008 21:55:26 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/wordpress/?p=1417#comment-87</guid>
		<description>&lt;p&gt;As I said it&#039;s a matter of judgment. It&#039;s not black and white. Interfaces (in the syntactical sense) may be a necessity if you really want to use type hinting, but ideally an interface should express a meaningful abstraction, and that abstraction is not likely to be stable in the beginning. In that case, I&#039;m inclined to say it&#039;s better to avoid both the interface and the type hints rather than have an interface that&#039;s just a technical trick. I suggest that type hinting may be more useful for a stable interface, and that&#039;s just the kind of thing you will be seeking if you&#039;re developing a framework. As for dependency, I said dependency on the class (or interface, I should have added) name. There is a dependendency if you don&#039;t use a type hint, and it&#039;s less specific, not just less explicit.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>As I said it&#8217;s a matter of judgment. It&#8217;s not black and white. Interfaces (in the syntactical sense) may be a necessity if you really want to use type hinting, but ideally an interface should express a meaningful abstraction, and that abstraction is not likely to be stable in the beginning. In that case, I&#8217;m inclined to say it&#8217;s better to avoid both the interface and the type hints rather than have an interface that&#8217;s just a technical trick. I suggest that type hinting may be more useful for a stable interface, and that&#8217;s just the kind of thing you will be seeking if you&#8217;re developing a framework. As for dependency, I said dependency on the class (or interface, I should have added) name. There is a dependendency if you don&#8217;t use a type hint, and it&#8217;s less specific, not just less explicit.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Koen</title>
		<link>http://blog.agilephp.com/2008/09/07/type-hints-are-more-useful-for-scalars-than-objects/comment-page-1/#comment-86</link>
		<dc:creator>Koen</dc:creator>
		<pubDate>Sun, 07 Sep 2008 21:05:40 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/wordpress/?p=1417#comment-86</guid>
		<description>&lt;p&gt;If you&#039;re not using the interface/type hint you have the dependency also. The difference is that now it is not explicit.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>If you&#8217;re not using the interface/type hint you have the dependency also. The difference is that now it is not explicit.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mathias</title>
		<link>http://blog.agilephp.com/2008/09/07/type-hints-are-more-useful-for-scalars-than-objects/comment-page-1/#comment-85</link>
		<dc:creator>Mathias</dc:creator>
		<pubDate>Sun, 07 Sep 2008 18:12:21 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/wordpress/?p=1417#comment-85</guid>
		<description>&lt;p&gt;My team is working on a framework, and we&#039;re making more and more use of interfaces and type hinting. This way the method is basically saying: I don&#039;t care what the class the object has, as long as it&#039;s abiding by these rules. Although haven&#039;t actually encountered a lot of bugs that could have been prevented by object type hinting, using it gives me a warm feeling of &#039;less can go wrong&#039;. &lt;/p&gt;
&lt;p&gt;And yes, I don&#039;t understand either why php doesn&#039;t have native scalar hinting :-)&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>My team is working on a framework, and we&#8217;re making more and more use of interfaces and type hinting. This way the method is basically saying: I don&#8217;t care what the class the object has, as long as it&#8217;s abiding by these rules. Although haven&#8217;t actually encountered a lot of bugs that could have been prevented by object type hinting, using it gives me a warm feeling of &#8216;less can go wrong&#8217;. </p>
<p>And yes, I don&#8217;t understand either why php doesn&#8217;t have native scalar hinting <img src='http://blog.agilephp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Lively</title>
		<link>http://blog.agilephp.com/2008/09/07/type-hints-are-more-useful-for-scalars-than-objects/comment-page-1/#comment-84</link>
		<dc:creator>Mike Lively</dc:creator>
		<pubDate>Sun, 07 Sep 2008 16:36:11 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/wordpress/?p=1417#comment-84</guid>
		<description>&lt;p&gt;I suppose to some extent you are right about limited usefulness but in my opinion the value of them is that it can &lt;/p&gt;
&lt;p&gt;1. point you in the right direction alot sooner. Imagine you passed the wrong type of object but it just HAPPENS to have a function of the same name? That could be relatively annoying, capable of passing unit tests, and quite possible wouldn&#039;t throw any errors. It would just result in strange behavior that may or may not be immediately apparent.&lt;/p&gt;
&lt;p&gt;2. A call to a non-existing method is a fatal error. A call where the correct type is not passed in is a &quot;catchable&quot; fatal error. Now in practice this too probably doesn&#039;t mean much, but it does provide for more opportunities to recover or alert people to what is going on.&lt;/p&gt;
&lt;p&gt;Also, to address point 1. I think a mistake alot of people make is to not use interfaces as much. If you have a method call that expects a certain type of object that has say 10 public methods. If you only really need access to 2 of those methods then there is a very good chance that you are only trying to utilize one aspect of that class that could be segregated into an interface. This would make your code much more flexible while saving you from the potential headaches in my previous point.&lt;/p&gt;
&lt;p&gt;That all being said, scalar type hints would also be nice if they were native :).&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>I suppose to some extent you are right about limited usefulness but in my opinion the value of them is that it can </p>
<p>1. point you in the right direction alot sooner. Imagine you passed the wrong type of object but it just HAPPENS to have a function of the same name? That could be relatively annoying, capable of passing unit tests, and quite possible wouldn&#8217;t throw any errors. It would just result in strange behavior that may or may not be immediately apparent.</p>
<p>2. A call to a non-existing method is a fatal error. A call where the correct type is not passed in is a &#8220;catchable&#8221; fatal error. Now in practice this too probably doesn&#8217;t mean much, but it does provide for more opportunities to recover or alert people to what is going on.</p>
<p>Also, to address point 1. I think a mistake alot of people make is to not use interfaces as much. If you have a method call that expects a certain type of object that has say 10 public methods. If you only really need access to 2 of those methods then there is a very good chance that you are only trying to utilize one aspect of that class that could be segregated into an interface. This would make your code much more flexible while saving you from the potential headaches in my previous point.</p>
<p>That all being said, scalar type hints would also be nice if they were native <img src='http://blog.agilephp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
]]></content:encoded>
	</item>
</channel>
</rss>
