<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>船長日誌 &#187; testdrivendevelopment</title>
	<atom:link href="http://www.cslog.cn/tag/testdrivendevelopment/feed/zh-hant/" rel="self" type="application/rss+xml" />
	<link>http://www.cslog.cn</link>
	<description>最讓我激動的是不知道下一個星球上能發現什麼...</description>
	<lastBuildDate>Wed, 30 Jul 2025 16:06:05 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
		<item>
		<title>Extreme Programming and Test-Driven Development</title>
		<link>http://www.cslog.cn/Content/extreme-programming-and-test-driven-development/zh-hant/</link>
		<comments>http://www.cslog.cn/Content/extreme-programming-and-test-driven-development/zh-hant/#comments</comments>
		<pubDate>Sun, 06 May 2007 05:49:22 +0000</pubDate>
		<dc:creator>船長</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[rubyonrails]]></category>
		<category><![CDATA[softwareengineering]]></category>
		<category><![CDATA[testdrivendevelopment]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Extreme Programming Extreme Programming  &#8230; <a href="http://www.cslog.cn/Content/extreme-programming-and-test-driven-development/zh-hant/">繼續閱讀 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong><font color="#ff6600">Extreme Programming</font></strong><br />
Extreme Programming (or XP) is a <strong><font color="#0000ff">software engineering methodology</font></strong>, the most prominent of several agile software development methodologies.</p>
<p>Extreme Programming Explained describes Extreme Programming as being:<br />
&nbsp;&nbsp;&nbsp; * An attempt to reconcile <strong>humanity</strong> and <strong>productivity</strong><br />
&nbsp;&nbsp;&nbsp; * A mechanism for social change<br />
&nbsp;&nbsp;&nbsp; * A path to improvement<br />
&nbsp;&nbsp;&nbsp; * A style of <strong>development</strong><br />
&nbsp;&nbsp;&nbsp; * A software development discipline</p>
<p><strong><br />
</strong><strong><font color="#ff6600">Test-Driven Development</font></strong><br />
<strong>The goal of TDD is to write clean code that works. </strong></p>
<p><strong><font color="#ff6600">What is Test-Driven Development?</font></strong><br />
Test-Driven Development (TDD) is <strong><font color="#0000ff">a software development technique</font></strong> that involves repeatedly first writing a test case and then implementing only the code necessary to pass the test. Test-driven development is a method of designing software, not merely a method of testing.</p>
<p>In addition to normal &ldquo;did it pass?&rdquo; testing, you can go the opposite route. By testing your application where the weak points are, you can fix it before it ever becomes an issue.</p>
<p><strong><font color="#ff6600">Test-Driven Development Cycle</font></strong><br />
<font color="#0000ff"><strong>1. Add a test</strong></font><br />
In order to write a test, the developer <strong><font color="#ff0000">must</font></strong> understand the specification and the requirements of the feature clearly. <br />
<strong><font color="#0000ff">2. Run all tests and see the new one fail</font></strong><br />
testing the tests<br />
<strong><font color="#0000ff">3. Write some code</font></strong><br />
It is important that the code written is only designed to pass the test; no further (and therefore untested) functionality should be predicted and &#8216;allowed for&#8217; at any stage.</p>
<p><font color="#808080"><em><strong>KISS</strong><br />
Keep It Simple, Stupid.<br />
Everything should be made as simple as possible, but no simpler.<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &#8211;Albert Einstein</em></p>
<p><em><strong>You Ain&#8217;t Gonna Need It</strong><br />
&#8216;You Ain&#8217;t Gonna Need It&#8217;(YAGNI), is a reminder for programmers that one should never add functionality until it is necessary. </em></font></p>
<p><strong><font color="#0000ff">4. Run the automated tests and see them succeed<br />
5. Refactor code</font></strong></p>
<p>
<font color="#808080"><strong>Refactoring</strong><br />
A code refactoring is any change to a computer program which improves its readability or simplifies its structure without changing its results.<br />
List of refactorings</p>
<p>&nbsp;&nbsp;&nbsp; * Encapsulate Field(e.g. providing methods that can be used to read/write to/from the field rather than accessing the field directly.) <br />
&nbsp;&nbsp;&nbsp; * Extract Method (to turn part of a larger method into a new method. By breaking down code in smaller pieces, it is more easily understandable. This is also applicable to functions)<br />
&nbsp;&nbsp;&nbsp; * Generalize Type (to making more general or more abstract some subset of the traits of a specific type. An example of generalizing a type would be moving a method from a child to a parent class for common use by all the parent class&#8217; children, not just the original child.)<br />
&nbsp;&nbsp;&nbsp; * Pull Up (moving a method from a Subclass into a Superclass. )<br />
&nbsp;&nbsp;&nbsp; * Push Down (moving a method from a SuperClass into a SubClass.)<br />
&nbsp;&nbsp;&nbsp; * Rename Method (changing the name of a method into a new one that better reveals its purpose).</font></p>
<p>The cycle is then repeated, starting with another new test to push forward the functionality. </p>
<p>&quot;Test-Driven Development Mantra&quot; is known as <font color="#ff0000">red</font>/<font color="#00ff00">green</font>/refactor where red means fail and green is pass.</p>
<p>
<strong><font color="#ff6600">Benefits</font></strong><br />
By focusing on the test cases first, one must imagine how the functionality will be used by clients (in this case, the test cases). Therefore, the programmer is <strong><font color="#0000ff">only concerned with the interface and not the implementation.</font></strong><br />
It allows a programmer to <strong><font color="#0000ff">focus on the task at hand</font></strong> as the first goal is to make the test pass. <br />
Ensuring that all written code is covered by a test. </p>
<p>
<strong><font color="#ff6600">Limitations</font></strong><br />
A test-driven development is only as good as its tests. </p>
<p>Reference<br />
<a href="http://en.wikipedia.org/wiki/Test-driven_development">http://en.wikipedia.org/wiki/Test-driven_development</a><br />
<a href="http://en.wikipedia.org/wiki/You_Ain%27t_Gonna_Need_It">http://en.wikipedia.org/wiki/You_Ain%27t_Gonna_Need_It</a><br />
<a href="http://en.wikipedia.org/wiki/Refactoring">http://en.wikipedia.org/wiki/Refactoring</a></p>
<p>Related Resources<br />
<a href="http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit.html">Test::Unit &#8211; Ruby Unit Testing Framework</a><br />
<a href="http://manuals.rubyonrails.com/read/book/5">A Guide to Testing the Rails<br />
</a><a href="http://blog.zenspider.com/archives/2006/04/test_driven_des.html">Test Driven Design for Ruby and Rails<br />
</a><a href="http://nubyonrails.com/articles/2006/08/24/ruby-rails-test-rails-cheat-sheet">Ruby, Rails, Test::Rails Cheat Sheet<br />
</a>
<div style="margin-top: 15px; font-style: italic">
<p>轉載請註明: 轉自<a href="http://www.cslog.cn/">船長日誌</a>, 本文鏈接地址: <a href="http://www.cslog.cn/Content/extreme-programming-and-test-driven-development/zh-hant/">http://www.cslog.cn/Content/extreme-programming-and-test-driven-development/zh-hant/</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.cslog.cn/Content/extreme-programming-and-test-driven-development/feed/zh-hant/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- WP Chinese Conversion Full Page Converted -->