<?xml version="1.0" encoding="utf-8" ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" type="text/css" href="//blog.8-p.info/2009/wp-content/themes/b8i/ALL.css" />

  <link rel="alternate" type="application/rss+xml"
             href="//blog.8-p.info/2009/feed" title="Japanese + English" />
  <link rel="alternate" type="application/atom+xml"
             href="//blog.8-p.info/2009/tag/lang-en/feed/atom" title="English" />

  <link rel="icon" href="//blog.8-p.info/favicon.ico" type="image/vnd.microsoft.icon" />
  <title>テストぬきリファクタリング - blog.8-p.info</title>

<link rel="EditURI" type="application/rsd+xml" title="RSD" href="//blog.8-p.info/2009/xmlrpc.php?rsd" />
<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="//blog.8-p.info/2009/wp-includes/wlwmanifest.xml" /> 


</head>

<body>

<div id="header">
  <div class="main">
    <h1><a href="/">blog.8-p.info</a></h1>
    <p>加藤和良 (1984年うまれ) の個人的なブログです。</p>
  </div>
  <div class="sidebar">
    <form method="get" action="//blog.8-p.info/2009/">
      <div id="search">
        <input type="text" class="text" id="searchKeyword"  name="s"
               value="" />
      </div>
    </form>
  </div>
</div>

<div id="body">
  <div class="entry" id="entry191">
  <h2 class="entry-title"><a href="//blog.8-p.info/2009/01/refactoring">テストぬきリファクタリング</a>
    (2)  </h2>
  <div class="yui-g meta">
    <div class="date yui-u first">
      2009-01-09 20:35    </div>
    <div class="tags yui-u">
          </div>
  </div>
  <div class="body"><p>開発者だけでできる自動化されたテスト (単体テストでも Selenium でも) なしの書き換えを「リファクタリング」というのは用語の誤用とまでいえるのか調べていた。</p>
<blockquote><p>単体テストを書かずに行っている「その行為」をリファクタリングと呼ぶのはやめてほしい。</p></blockquote>
<p>と <a href="http://kakutani.com/20040809.html#p01">角谷さんが書かれている</a> のと、Martin Fowler の <a href="http://capsctrl.que.jp/kdmsnr/wiki/bliki/?RefactoringMalapropism">リファクタリングの誤用</a> はみつけたんだけど、いまひとつ確信がもてない。</p>
<p>で「単体テストを書かずに行っている「その行為」をリファクタリングと呼ぶのはやめてほしい。/ 正確な定義ではなさそう」とはてなブックマークに書いたら</p>
<blockquote><p>id:kzys 「正確な定義」には記述されてないけど「堅実なテストは、リファクタリングをする上で欠かせない事前条件」(『リファクタリング』p.89)で、この条件は定義(pp.53-54)から導かれると思いますが、そういうことでなく?</p></blockquote>
<p>と、<a href="http://b.hatena.ne.jp/kakutani/20090107#bookmark-11565943">直々にコメントをいただいて</a>しまいました。びっくりした。</p>
<p>原典はまえ図書館で借りて通読したきりなので、読み返してみます。「コピペの繰り返しはプログラミングじゃないよ&#8230;」くらいの温度で「リファクタリングじゃない」とは思います。</p>
<p>ただ、わざわざテストの無いものまで「リファクタリング」と呼ぶ理由も無いですね。「コードの整理」でいいのかも。</p>
</div>
</div>

<!-- You can start editing here. -->

<div id="comments">

<div class="comment">
  <h3 class="alt" id="comment-13">
    <img alt='' src='http://www.gravatar.com/avatar/63a6bff89d692e21de20868202bc8dde?s=32&amp;d=identicon&amp;r=X' class='avatar avatar-32 photo' height='32' width='32' />    <a href='http://kakutani.com' rel='external nofollow' class='url'>かくたに</a>  </h3>
  <p>エントリを起こして返答いただき、かたじけないです。<br />
ありがとうございます。</p>
<p>私の脊髄反射はブクマコメントだったので100文字制限のなかでは「定義」まで書けませんでした。<br />
でも、読み返すことにつながるんだった結果的にはよかったです ;-)</p>
<p>ちなみに、refactoringとreworkingは区別されてます。 <a href="http://c2.com/cgi/wiki?WhatIsReworking" rel="nofollow">http://c2.com/cgi/wiki?WhatIsReworking</a></p>
<p>これも厳密な定義ではないと思いますが&#8221;Working Effectively with Legacy Code&#8221;で「テストがないコードはレガシーコードだ」と言っているのは、レガシーコードはリファクタリングできないからです。<br />
同書ではなにがそこまで彼を駆り立てるのかというぐらい、テストを書けるようにするための方法を模索しています(同書はそのうち翻訳がでるはずです)。</p>
<p>ご参考まで。</p>
</div>
<div class="comment">
  <h3 class="alt" id="comment-14">
    <img alt='' src='http://www.gravatar.com/avatar/7828b45f8396aa361d85cead01fd99ca?s=32&amp;d=identicon&amp;r=X' class='avatar avatar-32 photo' height='32' width='32' />    <a href='http://8-p.info/' rel='external nofollow' class='url'>kzys</a>  </h3>
  <p>WEwLC は読みました。読書会もいきましたよー。</p>
</div>
</div>

 


<h3 id="respond">Leave a Reply</h3>


<form action="//blog.8-p.info/2009/wp-comments-post.php" method="post" id="commentform">


<p><input type="text" name="author" id="author" value="" size="22" tabindex="1" aria-required='true' />
<label for="author"><small>Name (required)</small></label></p>

<p><input type="text" name="email" id="email" value="" size="22" tabindex="2" aria-required='true' />
<label for="email"><small>Mail (will not be published, for <a href="http://en.gravatar.com/">Gravatar</a>) (required)</small></label></p>

<p><input type="text" name="url" id="url" value="" size="22" tabindex="3" />
<label for="url"><small>Website</small></label></p>


<!--<p><small><strong>XHTML:</strong> You can use these tags: <code>&lt;a href=&quot;&quot; title=&quot;&quot;&gt; &lt;abbr title=&quot;&quot;&gt; &lt;acronym title=&quot;&quot;&gt; &lt;b&gt; &lt;blockquote cite=&quot;&quot;&gt; &lt;cite&gt; &lt;code&gt; &lt;del datetime=&quot;&quot;&gt; &lt;em&gt; &lt;i&gt; &lt;q cite=&quot;&quot;&gt; &lt;strike&gt; &lt;strong&gt; </code></small></p>-->

<p><textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p>

<p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
<input type="hidden" name="comment_post_ID" value="191" />
</p>

</form>


</div>

<div id="footer">Powered by <a href="http://wordpress.org/">WordPress</a></div>


<!-- Google Analytics -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-329758-2");
pageTracker._trackPageview();
</script>

<script type="text/javascript" src="//blog.8-p.info/2009/wp-content/themes/b8i/ALL.js"></script>

<script type="text/javascript">//<![CDATA[
(function () {
  var elements = document.body.getElementsByTagName('pre');
  var i, pre;
  for (i = 0; i < elements.length; i++) {
    pre = elements[i];
    if ((pre.innerText || pre.textContent).match(/^[%\(]/)) {
      ;
    } else {
      pre.className += ' prettyprint';
    }
  }
  prettyPrint();

  (new TextField($('searchKeyword'))).setPlaceholder('Search');
})();
//]]></script>

</body>
</html>
