<?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: Duck Typing</title>
	<atom:link href="http://www.barneyb.com/barneyblog/2006/10/16/duck-typing/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.barneyb.com/barneyblog/2006/10/16/duck-typing/</link>
	<description>Thoughts, rants, and even some code from the mind of Barney Boisvert.</description>
	<lastBuildDate>Thu, 11 Sep 2014 09:58:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Patrick McElhaney</title>
		<link>https://www.barneyb.com/barneyblog/2006/10/16/duck-typing/comment-page-1/#comment-437</link>
		<dc:creator>Patrick McElhaney</dc:creator>
		<pubDate>Tue, 17 Oct 2006 14:33:30 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=188#comment-437</guid>
		<description>I understand that type checking helps me identify errors. But making everything fit into compatible types takes a lot of brain power. I&#039;d rather devote that brain power directly to finding and fixing errors. 

In my experience, simplicity is the best defense against all kinds of errors. The simpler the code is, the better I understand it. The more I understand it, the easier it is to discover and fix errors. Duck typing allows me to make the code simpler.






</description>
		<content:encoded><![CDATA[<p>I understand that type checking helps me identify errors. But making everything fit into compatible types takes a lot of brain power. I'd rather devote that brain power directly to finding and fixing errors. </p>
<p>In my experience, simplicity is the best defense against all kinds of errors. The simpler the code is, the better I understand it. The more I understand it, the easier it is to discover and fix errors. Duck typing allows me to make the code simpler.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vince Bonfanti</title>
		<link>https://www.barneyb.com/barneyblog/2006/10/16/duck-typing/comment-page-1/#comment-436</link>
		<dc:creator>Vince Bonfanti</dc:creator>
		<pubDate>Tue, 17 Oct 2006 12:17:53 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=188#comment-436</guid>
		<description>Peter wrote: &quot;In my opinion the benefits of strong typing in CF are a little more modest because there is no compiler - just a different runtime error.&quot;

I agree that the benefits of strong typing is CF are less that what you&#039;d get in a compiled language, but I think the &quot;just a different runtime error&quot; argument falsely implies that all runtime errors are the same--they&#039;re not. The relevant question is: when does the error get caught?

If you specify a CFC type for a CFARGUMENT tag, then you&#039;re going to catch the error as soon as you try to pass a CFC as a function parameter that doesn&#039;t match the required type--probably during development. If you use duck typing then there may be a path in your code that you miss during testing that isn&#039;t caught until the application is put into production. In some environments, fixing post-production bugs isn&#039;t a big deal; in others it&#039;s a major disaster.</description>
		<content:encoded><![CDATA[<p>Peter wrote: "In my opinion the benefits of strong typing in CF are a little more modest because there is no compiler &#8211; just a different runtime error."</p>
<p>I agree that the benefits of strong typing is CF are less that what you'd get in a compiled language, but I think the "just a different runtime error" argument falsely implies that all runtime errors are the same&#8211;they're not. The relevant question is: when does the error get caught?</p>
<p>If you specify a CFC type for a CFARGUMENT tag, then you're going to catch the error as soon as you try to pass a CFC as a function parameter that doesn't match the required type&#8211;probably during development. If you use duck typing then there may be a path in your code that you miss during testing that isn't caught until the application is put into production. In some environments, fixing post-production bugs isn't a big deal; in others it's a major disaster.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Bell</title>
		<link>https://www.barneyb.com/barneyblog/2006/10/16/duck-typing/comment-page-1/#comment-435</link>
		<dc:creator>Peter Bell</dc:creator>
		<pubDate>Tue, 17 Oct 2006 11:56:02 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=188#comment-435</guid>
		<description>@Ben - All it takes for code to fail is for you to forget to add one cfargument to one method. Usually that&#039;ll be caught early on in testing, but if the method is a really obscure path, it may not be. Then you start getting phone calls from customers saying your site isn&#039;t working but you can&#039;t replicate the error.

In the end it turns out that if someones session times out WHILE they are checking out AND if they have not previously ordered from you before (which is where your initial testing fails as you didn&#039;t blow away your cookies before testing), it runs code to pull up their default data (and this is the only time this particular path is fully exercised - your general model call works fine), but your controller in this one case forgets to pass the appropriate property back from the method call and doesn&#039;t fully initialize your cart so they get a &quot;cannot check out&quot; error.

Now imagine hundreds of thousands of lines of code, large teams of programmers and daily builds with new features. Good news: you don&#039;t have to waste time with a compiler. Bad news: you have just been appointed head of QA and it is your ass if these bugs aren&#039;t fixed by 3pm!!!

A compiler is not a silver bullet. There are all kinds of problems that a compiler won&#039;t catch, but it will catch SOME of these problems so it does provide a real benefit for larger projects and teams. The question then is whether it is worth the cost of that benefit and your milage will vary. For my use case - no way!</description>
		<content:encoded><![CDATA[<p>@Ben &#8211; All it takes for code to fail is for you to forget to add one cfargument to one method. Usually that'll be caught early on in testing, but if the method is a really obscure path, it may not be. Then you start getting phone calls from customers saying your site isn't working but you can't replicate the error.</p>
<p>In the end it turns out that if someones session times out WHILE they are checking out AND if they have not previously ordered from you before (which is where your initial testing fails as you didn't blow away your cookies before testing), it runs code to pull up their default data (and this is the only time this particular path is fully exercised &#8211; your general model call works fine), but your controller in this one case forgets to pass the appropriate property back from the method call and doesn't fully initialize your cart so they get a "cannot check out" error.</p>
<p>Now imagine hundreds of thousands of lines of code, large teams of programmers and daily builds with new features. Good news: you don't have to waste time with a compiler. Bad news: you have just been appointed head of QA and it is your ass if these bugs aren't fixed by 3pm!!!</p>
<p>A compiler is not a silver bullet. There are all kinds of problems that a compiler won't catch, but it will catch SOME of these problems so it does provide a real benefit for larger projects and teams. The question then is whether it is worth the cost of that benefit and your milage will vary. For my use case &#8211; no way!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Yamabe</title>
		<link>https://www.barneyb.com/barneyblog/2006/10/16/duck-typing/comment-page-1/#comment-434</link>
		<dc:creator>Brian Yamabe</dc:creator>
		<pubDate>Tue, 17 Oct 2006 11:40:53 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=188#comment-434</guid>
		<description>By your definition of &quot;perfect&quot; unit test, then yes, because the dynamic typing proponents say to use TDD or something like that, so you only write code that addresses a failing test.  I&#039;m not saying that you will have &quot;perfect&quot; tests that will handle all situations that can be encountered.  The argument is that you can&#039;t know if your code correctly handles a situation unless you have a test for the situation regardless of whether the programming language is dynamically or statically typed.  The compiler is just another unit test.</description>
		<content:encoded><![CDATA[<p>By your definition of "perfect" unit test, then yes, because the dynamic typing proponents say to use TDD or something like that, so you only write code that addresses a failing test.  I'm not saying that you will have "perfect" tests that will handle all situations that can be encountered.  The argument is that you can't know if your code correctly handles a situation unless you have a test for the situation regardless of whether the programming language is dynamically or statically typed.  The compiler is just another unit test.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Nadel</title>
		<link>https://www.barneyb.com/barneyblog/2006/10/16/duck-typing/comment-page-1/#comment-433</link>
		<dc:creator>Ben Nadel</dc:creator>
		<pubDate>Tue, 17 Oct 2006 11:34:47 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=188#comment-433</guid>
		<description>Vince,

I agree, no one can write perfect code. I put errors up on the production site all the time .... er, um... I mean... my co-workers put errors up on the live sites all the time....

But, these are usually minor, non-mission critial errors. I feel that things where type-checking is involved are errors that are BIG and should be caught with even the least amount of testing.

And, even if something important does slip through, I think it&#039;s a rare case where the &quot;corruption&quot; of data would be so huge that we couldn&#039;t fix it and debug. Of course that changes from project to project (I have never built anything for a bank with money issues and 4 jillion transactions a second).

So, not to ramble, I am sure there are &quot;edge&quot; cases where any issue on the live server can result in massive amounts of data corruption, BUT, I feel that in 99.9% of the cases, that&#039;s just not going to happen.

This reminds me of something my digital logic professor talked about once in engineering... He said that&#039;s the difference between &quot;Computer Scientists&quot; and &quot;Computer Engineers&quot;: CS&#039;s are concerned with theory - what about that one case or the complexity of a problem when it appraoaches N and such nonsesnse. Then you have the CE&#039;s who don&#039;t care so much about theory, they care about numbers: sure a problem has exponential complexity, but I know that this system will never go above &quot;X&quot; and therefore, I don&#039;t care about the theory, I know it will always be fast.

Here endeth the rambling.</description>
		<content:encoded><![CDATA[<p>Vince,</p>
<p>I agree, no one can write perfect code. I put errors up on the production site all the time &#8230;. er, um&#8230; I mean&#8230; my co-workers put errors up on the live sites all the time&#8230;.</p>
<p>But, these are usually minor, non-mission critial errors. I feel that things where type-checking is involved are errors that are BIG and should be caught with even the least amount of testing.</p>
<p>And, even if something important does slip through, I think it's a rare case where the "corruption" of data would be so huge that we couldn't fix it and debug. Of course that changes from project to project (I have never built anything for a bank with money issues and 4 jillion transactions a second).</p>
<p>So, not to ramble, I am sure there are "edge" cases where any issue on the live server can result in massive amounts of data corruption, BUT, I feel that in 99.9% of the cases, that's just not going to happen.</p>
<p>This reminds me of something my digital logic professor talked about once in engineering&#8230; He said that's the difference between "Computer Scientists" and "Computer Engineers": CS's are concerned with theory &#8211; what about that one case or the complexity of a problem when it appraoaches N and such nonsesnse. Then you have the CE's who don't care so much about theory, they care about numbers: sure a problem has exponential complexity, but I know that this system will never go above "X" and therefore, I don't care about the theory, I know it will always be fast.</p>
<p>Here endeth the rambling.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Bell</title>
		<link>https://www.barneyb.com/barneyblog/2006/10/16/duck-typing/comment-page-1/#comment-432</link>
		<dc:creator>Peter Bell</dc:creator>
		<pubDate>Tue, 17 Oct 2006 11:30:50 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=188#comment-432</guid>
		<description>I&#039;m with Vince on this. I think it is a little unrealistic to assume 100% code coverage from unit tests. On an associated note, can anyone recommend a code coverage engine for CF? I know there are tools for Java and .NET, but I&#039;m not sure I&#039;ve come across a tool which identified percentage coverage of CF code based on a given set of unit tests. Without such a tool, I think the chances of getting 100% code coverage are pretty low on a complex project. 

The compiler isn&#039;t a silver bullet. It&#039;s like a seatbelt in a car. It doesn&#039;t help if someone shoots you, but in a fender bender it may just save your life.

Also, Sean, you don&#039;t just &quot;go to production&quot;. With ongoing maintenance and frequent builds, unless you have 100% coverage in your automated unit tests (I&#039;m assuming everyone is using automated unit tests as part of their build process) the compiler just catches one more class of errors in advance. That isn&#039;t a bad thing.

Now, whether a compiler is worth what it costs in terms of additional complexity required just to support explicit typing - that&#039;s a whole other matter.

Also to clarify, this is a discussion (for me) between true explicit typing (e.g. Java) and true dynamic typing (e.g. CF). In my opinion the benefits of strong typing in CF are a little more modest because there is no compiler - just a different runtime error.</description>
		<content:encoded><![CDATA[<p>I'm with Vince on this. I think it is a little unrealistic to assume 100% code coverage from unit tests. On an associated note, can anyone recommend a code coverage engine for CF? I know there are tools for Java and .NET, but I'm not sure I've come across a tool which identified percentage coverage of CF code based on a given set of unit tests. Without such a tool, I think the chances of getting 100% code coverage are pretty low on a complex project. </p>
<p>The compiler isn't a silver bullet. It's like a seatbelt in a car. It doesn't help if someone shoots you, but in a fender bender it may just save your life.</p>
<p>Also, Sean, you don't just "go to production". With ongoing maintenance and frequent builds, unless you have 100% coverage in your automated unit tests (I'm assuming everyone is using automated unit tests as part of their build process) the compiler just catches one more class of errors in advance. That isn't a bad thing.</p>
<p>Now, whether a compiler is worth what it costs in terms of additional complexity required just to support explicit typing &#8211; that's a whole other matter.</p>
<p>Also to clarify, this is a discussion (for me) between true explicit typing (e.g. Java) and true dynamic typing (e.g. CF). In my opinion the benefits of strong typing in CF are a little more modest because there is no compiler &#8211; just a different runtime error.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vince Bonfanti</title>
		<link>https://www.barneyb.com/barneyblog/2006/10/16/duck-typing/comment-page-1/#comment-431</link>
		<dc:creator>Vince Bonfanti</dc:creator>
		<pubDate>Tue, 17 Oct 2006 11:15:12 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=188#comment-431</guid>
		<description>Brian writes: &quot;The dynamic crowd would say that there shouldn&#039;t be a code path that doesn&#039;t have a unit test.&quot;

Doesn&#039;t that imply that you&#039;re able to write &quot;perfect&quot; unit tests; that is, that your unit tests provide 100% code coverage? If you can&#039;t write perfect code in the first place (no one can), what makes you think you can write perfect unit tests? That&#039;s why I&#039;d rather rely on the compiler to automatically catch as many errors as it can before I run my unit tests.</description>
		<content:encoded><![CDATA[<p>Brian writes: "The dynamic crowd would say that there shouldn't be a code path that doesn't have a unit test."</p>
<p>Doesn't that imply that you're able to write "perfect" unit tests; that is, that your unit tests provide 100% code coverage? If you can't write perfect code in the first place (no one can), what makes you think you can write perfect unit tests? That's why I'd rather rely on the compiler to automatically catch as many errors as it can before I run my unit tests.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean Corfield</title>
		<link>https://www.barneyb.com/barneyblog/2006/10/16/duck-typing/comment-page-1/#comment-430</link>
		<dc:creator>Sean Corfield</dc:creator>
		<pubDate>Tue, 17 Oct 2006 05:54:27 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=188#comment-430</guid>
		<description>I&#039;m with Ben on this... and Brian... By the time you go to production you should already have code that can&#039;t &quot;randomly&quot; pass objects that don&#039;t implement the right method. That&#039;s why I think Barney&#039;s argument is somewhat specious...</description>
		<content:encoded><![CDATA[<p>I'm with Ben on this&#8230; and Brian&#8230; By the time you go to production you should already have code that can't "randomly" pass objects that don't implement the right method. That's why I think Barney's argument is somewhat specious&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Yamabe</title>
		<link>https://www.barneyb.com/barneyblog/2006/10/16/duck-typing/comment-page-1/#comment-429</link>
		<dc:creator>Brian Yamabe</dc:creator>
		<pubDate>Tue, 17 Oct 2006 02:57:38 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=188#comment-429</guid>
		<description>I&#039;ve now seen several of these articles that point out valid concerns with dynamic languages.  What the static typing proponents are missing is one of the pillars of the dynamic typing crowd and that is unit testing.  Peter, in you comments you state, &quot;... it would only be caught if the unit codes executed the right code path.&quot;  The dynamic crowd would say that there shouldn&#039;t be a code path that doesn&#039;t have a unit test.  If you don&#039;t have a unit test for the code path it doesn&#039;t matter whether the program compiles, you can&#039;t prove that it&#039;s correct.</description>
		<content:encoded><![CDATA[<p>I've now seen several of these articles that point out valid concerns with dynamic languages.  What the static typing proponents are missing is one of the pillars of the dynamic typing crowd and that is unit testing.  Peter, in you comments you state, "&#8230; it would only be caught if the unit codes executed the right code path."  The dynamic crowd would say that there shouldn't be a code path that doesn't have a unit test.  If you don't have a unit test for the code path it doesn't matter whether the program compiles, you can't prove that it's correct.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Bell</title>
		<link>https://www.barneyb.com/barneyblog/2006/10/16/duck-typing/comment-page-1/#comment-428</link>
		<dc:creator>Peter Bell</dc:creator>
		<pubDate>Tue, 17 Oct 2006 01:30:57 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=188#comment-428</guid>
		<description>Reading my own post I wasn&#039;t really clear. Key point is that with dynamic typing I could not fully implement the controller interface and it would only be caught if the unit codes executed the right code path. With static typing my code wouldn&#039;t even compile.

It is not that you can&#039;t have interfaces in a dynamically typed language, but you rely on documentation or programming conventions rather than having language features to enforce the contract.</description>
		<content:encoded><![CDATA[<p>Reading my own post I wasn't really clear. Key point is that with dynamic typing I could not fully implement the controller interface and it would only be caught if the unit codes executed the right code path. With static typing my code wouldn't even compile.</p>
<p>It is not that you can't have interfaces in a dynamically typed language, but you rely on documentation or programming conventions rather than having language features to enforce the contract.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
