<?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: jsContract: Design by Contract library</title>
	<atom:link href="http://ajaxian.com/archives/jscontract/feed" rel="self" type="application/rss+xml" />
	<link>http://ajaxian.com/archives/jscontract</link>
	<description>Cleaning up the web with Ajax</description>
	<lastBuildDate>Thu, 09 Feb 2012 06:55:33 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
	<item>
		<title>By: neonstalwart</title>
		<link>http://ajaxian.com/archives/jscontract/comment-page-1#comment-278739</link>
		<dc:creator>neonstalwart</dc:creator>
		<pubDate>Sat, 06 Feb 2010 20:33:02 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8528#comment-278739</guid>
		<description>@zaach - i agree.  it would seem like AOP would be a better approach than compilation.  this is an interesting post about &lt;a href=&#039;http://lazutkin.com/blog/2008/may/18/aop-aspect-javascript-dojo/&#039; title=&#039;http://lazutkin.com/blog/2008/may/18/aop-aspect-javascript-dojo/&#039; rel=&quot;nofollow&quot;&gt;AOP with JavaScript and Dojo&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>@zaach &#8211; i agree.  it would seem like AOP would be a better approach than compilation.  this is an interesting post about <a href='http://lazutkin.com/blog/2008/may/18/aop-aspect-javascript-dojo/' title='http://lazutkin.com/blog/2008/may/18/aop-aspect-javascript-dojo/' rel="nofollow">AOP with JavaScript and Dojo</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: oyvindkinsey</title>
		<link>http://ajaxian.com/archives/jscontract/comment-page-1#comment-278714</link>
		<dc:creator>oyvindkinsey</dc:creator>
		<pubDate>Fri, 05 Feb 2010 15:16:43 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8528#comment-278714</guid>
		<description>@BenGerrisen You are absolutely right here, by doing this we are taking a step beyond just write &gt; execute. But then again, anyone doing javascript for ES should already be running the scripts through tools like JSLint etc as part of the build process any way, this is just the same.
.
For instance, with my easyXDM project components are spread on several files for easy editing, but during &#039;compilation&#039; they are all combined, checked for validity using jslint, strings are being replaced, the code separated into different versions based on conditional statements in comments, and finally its compressed. Adding this on top should not be a hassle for anyone _really_ javascript development.
. 
Now, something that would be fun would be to extend the parser used by JSLint to support JSDoc statements - then that could actually check for types! I&#039;m gonna look into this :)</description>
		<content:encoded><![CDATA[<p>@BenGerrisen You are absolutely right here, by doing this we are taking a step beyond just write &gt; execute. But then again, anyone doing javascript for ES should already be running the scripts through tools like JSLint etc as part of the build process any way, this is just the same.<br />
.<br />
For instance, with my easyXDM project components are spread on several files for easy editing, but during &#8216;compilation&#8217; they are all combined, checked for validity using jslint, strings are being replaced, the code separated into different versions based on conditional statements in comments, and finally its compressed. Adding this on top should not be a hassle for anyone _really_ javascript development.<br />
.<br />
Now, something that would be fun would be to extend the parser used by JSLint to support JSDoc statements &#8211; then that could actually check for types! I&#8217;m gonna look into this :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zaach</title>
		<link>http://ajaxian.com/archives/jscontract/comment-page-1#comment-278713</link>
		<dc:creator>zaach</dc:creator>
		<pubDate>Fri, 05 Feb 2010 15:12:00 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8528#comment-278713</guid>
		<description>Couldn&#039;t you use an AOP approach instead of a compilation step? You would only be able to check the inputs and output of a function, but that seems to be the main use case. An advantage is you could keep all the contract code in its own file, like a unit test, though unlike a unit test it would be mixed in to live code.</description>
		<content:encoded><![CDATA[<p>Couldn&#8217;t you use an AOP approach instead of a compilation step? You would only be able to check the inputs and output of a function, but that seems to be the main use case. An advantage is you could keep all the contract code in its own file, like a unit test, though unlike a unit test it would be mixed in to live code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BenGerrissen</title>
		<link>http://ajaxian.com/archives/jscontract/comment-page-1#comment-278711</link>
		<dc:creator>BenGerrissen</dc:creator>
		<pubDate>Fri, 05 Feb 2010 14:02:52 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8528#comment-278711</guid>
		<description>@CliveDangerous, it&#039;s for bulky complex ES applications. It&#039;s indeed not for websites with minute ammounts of ES code.
.
@oyvindkinsey &amp; FredrikB, thats basically what classical OO, type casting, strict typing and interfaces is used for in for example Java, thats currently my only point of reference for domain specific languages ;) The compiler then sorts and tests it on argument correctness etc. but then Java is hardly a dynamic language.
.
This kind of utility is exceptionally useful, but requires a compilation step. I love these kind of innovations and tools, though what we really need at this point, is fantastic IDE love and a good compiler to allow for non ES standard extra utility. I want the WHOLE package, not a snippet ;)
.
And there also lies the jest of things... ES developers are still split between IDE/Tools and just doing everything with .js files manually. As soon as someone mentions the word &#039;compiler&#039; people will stand on their hindlegs because it means change. For me it&#039;s irritating as hell to see domain specific language/platform dependence in great tools.
.
I am rambling offtopic.. so shutting up now =P</description>
		<content:encoded><![CDATA[<p>@CliveDangerous, it&#8217;s for bulky complex ES applications. It&#8217;s indeed not for websites with minute ammounts of ES code.<br />
.<br />
@oyvindkinsey &amp; FredrikB, thats basically what classical OO, type casting, strict typing and interfaces is used for in for example Java, thats currently my only point of reference for domain specific languages ;) The compiler then sorts and tests it on argument correctness etc. but then Java is hardly a dynamic language.<br />
.<br />
This kind of utility is exceptionally useful, but requires a compilation step. I love these kind of innovations and tools, though what we really need at this point, is fantastic IDE love and a good compiler to allow for non ES standard extra utility. I want the WHOLE package, not a snippet ;)<br />
.<br />
And there also lies the jest of things&#8230; ES developers are still split between IDE/Tools and just doing everything with .js files manually. As soon as someone mentions the word &#8216;compiler&#8217; people will stand on their hindlegs because it means change. For me it&#8217;s irritating as hell to see domain specific language/platform dependence in great tools.<br />
.<br />
I am rambling offtopic.. so shutting up now =P</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: oyvindkinsey</title>
		<link>http://ajaxian.com/archives/jscontract/comment-page-1#comment-278709</link>
		<dc:creator>oyvindkinsey</dc:creator>
		<pubDate>Fri, 05 Feb 2010 12:28:14 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8528#comment-278709</guid>
		<description>@CliveDangerous
One of my biggest projects involve over 18k lines (not counting any frameworks) and uses webservices for data access. The primary page might not be reloaded for weeks (some of our customers keep the application open at all times), and is used from all platforms with browsers ranging form IE6 to Chrome - if one piece of data become inconsistent it will probably affect many different areas of the code, these errors will be extremely hard to debug. 

If I had pre- and postconditions on all of my methods that interface with  the user (dom-events etc) and that manipulated data I would KNOW where the bug FIRST occurred, where the bug IS, not just where it became noticeable, where it caused hours of work to be lost by the client.</description>
		<content:encoded><![CDATA[<p>@CliveDangerous<br />
One of my biggest projects involve over 18k lines (not counting any frameworks) and uses webservices for data access. The primary page might not be reloaded for weeks (some of our customers keep the application open at all times), and is used from all platforms with browsers ranging form IE6 to Chrome &#8211; if one piece of data become inconsistent it will probably affect many different areas of the code, these errors will be extremely hard to debug. </p>
<p>If I had pre- and postconditions on all of my methods that interface with  the user (dom-events etc) and that manipulated data I would KNOW where the bug FIRST occurred, where the bug IS, not just where it became noticeable, where it caused hours of work to be lost by the client.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: CliveDangerous</title>
		<link>http://ajaxian.com/archives/jscontract/comment-page-1#comment-278705</link>
		<dc:creator>CliveDangerous</dc:creator>
		<pubDate>Fri, 05 Feb 2010 09:24:32 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8528#comment-278705</guid>
		<description>@BenGerrissen, I understand the point of Design by Contract, I just don&#039;t really see much benefit adding it to Javascript. I&#039;ve worked on a few very js-heavy websites, and I can&#039;t imagine DbC doing anything other then making development take twice as long.</description>
		<content:encoded><![CDATA[<p>@BenGerrissen, I understand the point of Design by Contract, I just don&#8217;t really see much benefit adding it to Javascript. I&#8217;ve worked on a few very js-heavy websites, and I can&#8217;t imagine DbC doing anything other then making development take twice as long.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: oyvindkinsey</title>
		<link>http://ajaxian.com/archives/jscontract/comment-page-1#comment-278704</link>
		<dc:creator>oyvindkinsey</dc:creator>
		<pubDate>Fri, 05 Feb 2010 08:39:08 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8528#comment-278704</guid>
		<description>@PeterMichaux
I use js-build-tools for things like that, if offers conditional statements like
        // #ifdef debug
        codeThatRunWhenTheDebugFlagIsSet();
        // #endif
        // #ifdef contract 
        ....
@ywg
I&#039;ll think about just parsing comments and generating the contracts from this - but this means that you will always have to instrument it even to have the input validated.</description>
		<content:encoded><![CDATA[<p>@PeterMichaux<br />
I use js-build-tools for things like that, if offers conditional statements like<br />
        // #ifdef debug<br />
        codeThatRunWhenTheDebugFlagIsSet();<br />
        // #endif<br />
        // #ifdef contract<br />
        &#8230;.<br />
@ywg<br />
I&#8217;ll think about just parsing comments and generating the contracts from this &#8211; but this means that you will always have to instrument it even to have the input validated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ywg</title>
		<link>http://ajaxian.com/archives/jscontract/comment-page-1#comment-278703</link>
		<dc:creator>ywg</dc:creator>
		<pubDate>Fri, 05 Feb 2010 06:51:49 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8528#comment-278703</guid>
		<description>At first I was skeptical, but it seems quite handy, I&#039;ll certainly give it a try.
.
I think that what disturb people the most is the confusion between contract and production code. Using regular javascript syntax introduce noise and make the function harder to read. If you use some alternative notation I think it&#039;ll be easier for people to dip in.
.
Something like java annotations
@contract expectNumber(a);

or a special inline documentation field
/**
 * @contract-start
 * expectNumber(a);
 * @contract-end
 */</description>
		<content:encoded><![CDATA[<p>At first I was skeptical, but it seems quite handy, I&#8217;ll certainly give it a try.<br />
.<br />
I think that what disturb people the most is the confusion between contract and production code. Using regular javascript syntax introduce noise and make the function harder to read. If you use some alternative notation I think it&#8217;ll be easier for people to dip in.<br />
.<br />
Something like java annotations<br />
@contract expectNumber(a);</p>
<p>or a special inline documentation field<br />
/**<br />
 * @contract-start<br />
 * expectNumber(a);<br />
 * @contract-end<br />
 */</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: PeterMichaux</title>
		<link>http://ajaxian.com/archives/jscontract/comment-page-1#comment-278702</link>
		<dc:creator>PeterMichaux</dc:creator>
		<pubDate>Fri, 05 Feb 2010 06:30:37 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8528#comment-278702</guid>
		<description>All that bulk is fine during debugging but worth marking with some comments for stripping before putting into production if possible.

function foo(a, b) {
  /* DEBUG BEGIN */
  // checks here
  /* DEBUG END */
  // normal body of function for production
}</description>
		<content:encoded><![CDATA[<p>All that bulk is fine during debugging but worth marking with some comments for stripping before putting into production if possible.</p>
<p>function foo(a, b) {<br />
  /* DEBUG BEGIN */<br />
  // checks here<br />
  /* DEBUG END */<br />
  // normal body of function for production<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: oyvindkinsey</title>
		<link>http://ajaxian.com/archives/jscontract/comment-page-1#comment-278697</link>
		<dc:creator>oyvindkinsey</dc:creator>
		<pubDate>Thu, 04 Feb 2010 19:21:40 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8528#comment-278697</guid>
		<description>For those who want a better example, see this one http://kinsey.no/projects/jsContract/test2.html</description>
		<content:encoded><![CDATA[<p>For those who want a better example, see this one <a href="http://kinsey.no/projects/jsContract/test2.html" rel="nofollow">http://kinsey.no/projects/jsContract/test2.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: oyvindkinsey</title>
		<link>http://ajaxian.com/archives/jscontract/comment-page-1#comment-278696</link>
		<dc:creator>oyvindkinsey</dc:creator>
		<pubDate>Thu, 04 Feb 2010 18:22:20 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8528#comment-278696</guid>
		<description>I&#039;m not an DbC evangelist or something, I have just dipped my toes in it, and I do see many advantages with using this - and I am not saying that this should be used instead of unit testing - but I am saying that it fits nicely with TDD as you can start by specifying  the contract and then improve the code until it doesn&#039;t fail anymore - just like Red-Green testing.

The advantage this does have over unit testing is that unit tests will by definition never run under the intended conditions, in a browser with a stupid user doing all sorts of things he is not supposed to do, request timing out, connection failing etc.. 

Code contracts on the other hand CAN, they can be in effect under normal usage and can help identify all the small things that you never ever imagined could happen - like a function that returns .childNodes[0] of some div suddenly returns a textnode instead of the DIV you KNOW is there, wtf?</description>
		<content:encoded><![CDATA[<p>I&#8217;m not an DbC evangelist or something, I have just dipped my toes in it, and I do see many advantages with using this &#8211; and I am not saying that this should be used instead of unit testing &#8211; but I am saying that it fits nicely with TDD as you can start by specifying  the contract and then improve the code until it doesn&#8217;t fail anymore &#8211; just like Red-Green testing.</p>
<p>The advantage this does have over unit testing is that unit tests will by definition never run under the intended conditions, in a browser with a stupid user doing all sorts of things he is not supposed to do, request timing out, connection failing etc.. </p>
<p>Code contracts on the other hand CAN, they can be in effect under normal usage and can help identify all the small things that you never ever imagined could happen &#8211; like a function that returns .childNodes[0] of some div suddenly returns a textnode instead of the DIV you KNOW is there, wtf?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: someguynameddylan</title>
		<link>http://ajaxian.com/archives/jscontract/comment-page-1#comment-278695</link>
		<dc:creator>someguynameddylan</dc:creator>
		<pubDate>Thu, 04 Feb 2010 17:57:37 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8528#comment-278695</guid>
		<description>That&#039;s a lot of code for multiplying and dividing 2 numbers.  I like the idea of this, but it makes my wrists hurt looking at the code.

I would prefer an interface that&#039;s a little more fluent like:

&lt;code&gt;
Contract.expectNumber (a, &#039;a&#039;)
.expectNumber (b, &#039;b&#039;)
.expectWhen(config.mode === &quot;divide&quot;, b&gt; 0, &quot;Divisor cannot be 0&quot;)
...
&lt;/code&gt;

I prefer unit testing, TDD to be exact because your test code is separated into its own file, no need to write a tool to remove all this, or extensive commenting out.

My 2 cents.</description>
		<content:encoded><![CDATA[<p>That&#8217;s a lot of code for multiplying and dividing 2 numbers.  I like the idea of this, but it makes my wrists hurt looking at the code.</p>
<p>I would prefer an interface that&#8217;s a little more fluent like:</p>
<p><code><br />
Contract.expectNumber (a, 'a')<br />
.expectNumber (b, 'b')<br />
.expectWhen(config.mode === "divide", b&gt; 0, "Divisor cannot be 0")<br />
...<br />
</code></p>
<p>I prefer unit testing, TDD to be exact because your test code is separated into its own file, no need to write a tool to remove all this, or extensive commenting out.</p>
<p>My 2 cents.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: oyvindkinsey</title>
		<link>http://ajaxian.com/archives/jscontract/comment-page-1#comment-278694</link>
		<dc:creator>oyvindkinsey</dc:creator>
		<pubDate>Thu, 04 Feb 2010 17:42:46 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8528#comment-278694</guid>
		<description>@AngusC 
Thats really not the point. You can use it to enforce types if you want to, but it is really used to enforced that the input is within an allowed range.
Take for instance a method that takes an object as input, and when done doing its magic returns obj.someProperty (which it thinks is a number).
What if the object given as input has no such property, or if this property is invalid? Then you will end up returning either &#039;undefined&#039; or some value you really did not mean to return - and you are non the wiser.
If you had an expect statement on the input, you would know at once that the argument did not match the contract.
And if you only had the guarantee statement then you would at least know that the output from your function was invalid.</description>
		<content:encoded><![CDATA[<p>@AngusC<br />
Thats really not the point. You can use it to enforce types if you want to, but it is really used to enforced that the input is within an allowed range.<br />
Take for instance a method that takes an object as input, and when done doing its magic returns obj.someProperty (which it thinks is a number).<br />
What if the object given as input has no such property, or if this property is invalid? Then you will end up returning either &#8216;undefined&#8217; or some value you really did not mean to return &#8211; and you are non the wiser.<br />
If you had an expect statement on the input, you would know at once that the argument did not match the contract.<br />
And if you only had the guarantee statement then you would at least know that the output from your function was invalid.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AngusC</title>
		<link>http://ajaxian.com/archives/jscontract/comment-page-1#comment-278693</link>
		<dc:creator>AngusC</dc:creator>
		<pubDate>Thu, 04 Feb 2010 17:03:23 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8528#comment-278693</guid>
		<description>I admire the effort, but isn&#039;t this just a clunky way of trying to impose strong typing on a language that is better off without it?</description>
		<content:encoded><![CDATA[<p>I admire the effort, but isn&#8217;t this just a clunky way of trying to impose strong typing on a language that is better off without it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: oyvindkinsey</title>
		<link>http://ajaxian.com/archives/jscontract/comment-page-1#comment-278692</link>
		<dc:creator>oyvindkinsey</dc:creator>
		<pubDate>Thu, 04 Feb 2010 15:29:06 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8528#comment-278692</guid>
		<description>@ywg Yes - this is not for production code as it does mean extra processing. The preprosessor will be extended with several options, removing contracts, adding jsDoc with the contract in human-readable form etc. (Did you notice that it can load and transform code dynamically at runtime? )

The ContractErrors will also be extended so that they better explain which condition failed.

I&#039;m thinking also to have an option to insert timing statements, try/catch blocks with a specified error handler - bundled with tools like http://eriwen.com/javascript/js-stack-trace/ and proper error reporting this can really help improve code quality.</description>
		<content:encoded><![CDATA[<p>@ywg Yes &#8211; this is not for production code as it does mean extra processing. The preprosessor will be extended with several options, removing contracts, adding jsDoc with the contract in human-readable form etc. (Did you notice that it can load and transform code dynamically at runtime? )</p>
<p>The ContractErrors will also be extended so that they better explain which condition failed.</p>
<p>I&#8217;m thinking also to have an option to insert timing statements, try/catch blocks with a specified error handler &#8211; bundled with tools like <a href="http://eriwen.com/javascript/js-stack-trace/" rel="nofollow">http://eriwen.com/javascript/js-stack-trace/</a> and proper error reporting this can really help improve code quality.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ywg</title>
		<link>http://ajaxian.com/archives/jscontract/comment-page-1#comment-278691</link>
		<dc:creator>ywg</dc:creator>
		<pubDate>Thu, 04 Feb 2010 15:17:15 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8528#comment-278691</guid>
		<description>@oyvindkinsey
I see. This is tipically the sort of thing you don&#039;t ship in the final product.
.
Will the preprocessor tool give an option to output a contract-less build for production ?</description>
		<content:encoded><![CDATA[<p>@oyvindkinsey<br />
I see. This is tipically the sort of thing you don&#8217;t ship in the final product.<br />
.<br />
Will the preprocessor tool give an option to output a contract-less build for production ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: oyvindkinsey</title>
		<link>http://ajaxian.com/archives/jscontract/comment-page-1#comment-278690</link>
		<dc:creator>oyvindkinsey</dc:creator>
		<pubDate>Thu, 04 Feb 2010 14:52:11 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8528#comment-278690</guid>
		<description>Think of it this way, its sort of like a unit test for each function, not just for the entire black box - it actually tests that all input and all output adheres to a strict contract, thereby guaranteeing that as long as the internal logic is correct, it will never fail. 

How many pieces of code doesn&#039;t rely on &#039;magic&#039; to work? (and by magic I mean undefined values, &quot;&quot; being evaluated as boolean false,  &quot;false&quot; and &quot;true&quot; as true, undefined as boolean false,  numbers being passed as strings etc ... )</description>
		<content:encoded><![CDATA[<p>Think of it this way, its sort of like a unit test for each function, not just for the entire black box &#8211; it actually tests that all input and all output adheres to a strict contract, thereby guaranteeing that as long as the internal logic is correct, it will never fail. </p>
<p>How many pieces of code doesn&#8217;t rely on &#8216;magic&#8217; to work? (and by magic I mean undefined values, &#8220;&#8221; being evaluated as boolean false,  &#8220;false&#8221; and &#8220;true&#8221; as true, undefined as boolean false,  numbers being passed as strings etc &#8230; )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: oyvindkinsey</title>
		<link>http://ajaxian.com/archives/jscontract/comment-page-1#comment-278689</link>
		<dc:creator>oyvindkinsey</dc:creator>
		<pubDate>Thu, 04 Feb 2010 14:42:25 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8528#comment-278689</guid>
		<description>@BenGerrissen
Code Contracts are not supposed to be present in production code - they are mainly used during development until the point where you can _guarantee_ that your code does what it is supposed to.

@ywg
With unit testing you are only testing the code with known inputs and checking for the correct output. With code contracts you can put code in real use (for instance as a beta) and with proper error handling you will detect the areas where the input is not properly guaranteed for due to browser quirks etc

Other than that, during development it both serves to document your code, it does input validation and it helps you implement complex functions by explicitly stating the contract that it must comply with.

I know firsthand that when writing javascript applications with &gt;20k lines you will never be able to really guarantee that the input (from browser events, etc) will be valid, and at all conditions are met.</description>
		<content:encoded><![CDATA[<p>@BenGerrissen<br />
Code Contracts are not supposed to be present in production code &#8211; they are mainly used during development until the point where you can _guarantee_ that your code does what it is supposed to.</p>
<p>@ywg<br />
With unit testing you are only testing the code with known inputs and checking for the correct output. With code contracts you can put code in real use (for instance as a beta) and with proper error handling you will detect the areas where the input is not properly guaranteed for due to browser quirks etc</p>
<p>Other than that, during development it both serves to document your code, it does input validation and it helps you implement complex functions by explicitly stating the contract that it must comply with.</p>
<p>I know firsthand that when writing javascript applications with &gt;20k lines you will never be able to really guarantee that the input (from browser events, etc) will be valid, and at all conditions are met.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: FredrikB</title>
		<link>http://ajaxian.com/archives/jscontract/comment-page-1#comment-278688</link>
		<dc:creator>FredrikB</dc:creator>
		<pubDate>Thu, 04 Feb 2010 14:24:34 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8528#comment-278688</guid>
		<description>@Ben
The main purpose of DbC isn&#039;t simple type checking.. DbC doesn&#039;t replace unit tests - but neither does the opposite.</description>
		<content:encoded><![CDATA[<p>@Ben<br />
The main purpose of DbC isn&#8217;t simple type checking.. DbC doesn&#8217;t replace unit tests &#8211; but neither does the opposite.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BenGerrissen</title>
		<link>http://ajaxian.com/archives/jscontract/comment-page-1#comment-278687</link>
		<dc:creator>BenGerrissen</dc:creator>
		<pubDate>Thu, 04 Feb 2010 13:56:05 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8528#comment-278687</guid>
		<description>@ywg, @CliveDangerous, it&#039;s mitigation from a Classical OO programmer point of view, &#039;solving&#039; the lack of strict typing and interfaces.
.
The lack of a compiler can be very traumatising for programmers comming from another discipline dabbling with JavaScript... Or worse *cough* real programmers *cough* are giving this chap a hard time about JS.</description>
		<content:encoded><![CDATA[<p>@ywg, @CliveDangerous, it&#8217;s mitigation from a Classical OO programmer point of view, &#8216;solving&#8217; the lack of strict typing and interfaces.<br />
.<br />
The lack of a compiler can be very traumatising for programmers comming from another discipline dabbling with JavaScript&#8230; Or worse *cough* real programmers *cough* are giving this chap a hard time about JS.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

