<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Tom Moertel's Weblog: Cost-reducing interfaces should be the focus</title>
    <link>http://blog.moertel.com/articles/2005/12/08/cost-reducing-interfaces-should-be-the-focus</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Quality rants on programming theory and stuff geeks like</description>
    <item>
      <title>Cost-reducing interfaces should be the focus</title>
      <description>&lt;p&gt;I have been following with interest the debate about &amp;#8220;humane&amp;#8221; 
vs. &amp;#8220;minimal&amp;#8221; interfaces, sparked recently by &lt;a href="http://www.cafeaulait.org/oldnews/news2005December6.html"&gt;Elliotte Rusty Harold&amp;#8217;s
response&lt;/a&gt; to
&lt;a href="http://martinfowler.com/bliki/HumaneInterface.html"&gt;Martin Fowler&amp;#8217;s HumaneInterface
post&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;Harold writes:&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;Martin Fowler&amp;#8217;s a really smart guy, and he&amp;#8217;s pretty reliably
right; but today he manages to get it 180° wrong. &lt;span class="caps"&gt;A 78&lt;/span&gt; method List
class is about three times as bad as a 25 method List class, not three
times as good. &lt;span class="caps"&gt;A 12&lt;/span&gt; method List class would be about twice as
good. Simplicity is a virtue for both users and implementers. There&amp;#8217;s
simply no reason for 78 methods in a basic List class.&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;The problem with Harold&amp;#8217;s argument is that he is using the
wrong goodness metric.  His metric is interface complexity when
it ought to be overall cost.&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;Cost is what counts.&lt;/strong&gt;  If adding methods (or making any change, for that matter) reduces the overall cost of
getting legitimate work done, it&amp;#8217;s the right thing to do.  That&amp;#8217;s
all there is to it.&lt;/p&gt;


	&lt;p&gt;Yes, adding methods to a library increases complexity and thus
increases the cost of understanding and using the library.
Adding methods to a library means asking users to make a small
investment of their time and mental capacity in exchange for the
promise of a later return &amp;#8211; clarity and code savings.  The duty of a
library designer, then, is to make sure that this return is
worthwhile, that the additions are useful enough and used frequently
enough to pay for themselves.&lt;/p&gt;


	&lt;p&gt;In &lt;a href="http://www.cafeaulait.org/oldnews/news2005December8.html"&gt;a later post&lt;/a&gt;,
Harold implicitly acknowledges the does-it-pay-for-itself test when he lists some methods from &lt;a href="http://www.ruby-doc.org/core/classes/Array.html"&gt;Ruby&amp;#8217;s Array class&lt;/a&gt; that he thinks are unjustified.  He writes:&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;Do you really need any of [these methods] getting in your way?
Possibly you need one or two of these methods; but how often, and how
many?&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;The thing is, I use many of the methods he lists.  Further, the ones I
don&amp;#8217;t use don&amp;#8217;t seem to get in my way.  In sum, those methods have
paid me back far more than I have invested in them.  Given this, why &lt;em&gt;shouldn&amp;#8217;t&lt;/em&gt; they be in the Array class?&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;m not saying that &amp;#8220;humane&amp;#8221; interfaces are better.  Rather, I&amp;#8217;m
saying that &lt;strong&gt;focusing on &amp;#8220;humane&amp;#8221; vs. &amp;#8220;minimal&amp;#8221; is missing the forest for
the trees.&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;Cost is what matters, so why shouldn&amp;#8217;t it be the focus?  Who cares if
that focus leads us to a &amp;#8220;humane&amp;#8221; interface one time and a &amp;#8220;minimal&amp;#8221; 
interface another?  With cost as our guide, we&amp;#8217;ll always arrive at a
good interface.&lt;/p&gt;</description>
      <pubDate>Thu, 08 Dec 2005 17:35:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:487847a070f866c536cf21a3e6103796</guid>
      <author>Tom Moertel</author>
      <link>http://blog.moertel.com/articles/2005/12/08/cost-reducing-interfaces-should-be-the-focus</link>
      <category>programming</category>
      <category>cost</category>
      <category>interfaces</category>
      <category>programming</category>
      <category>minimal</category>
      <category>humane</category>
      <trackback:ping>http://blog.moertel.com/articles/trackback/21</trackback:ping>
    </item>
    <item>
      <title>"Cost-reducing interfaces should be the focus" by peterb</title>
      <description>&lt;p&gt;I think Shalabh is mostly correct; phrased another way, the developer of a library may not be in a position to understand the costs.  The more users the library has, the harder this problem becomes.&lt;/p&gt;


	&lt;p&gt;There are also different costs at stake:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;maintainability of the library (fewer interfaces = better)&lt;/li&gt;
		&lt;li&gt;maintainability of code that uses your library (could go either way.  Fewer interfaces may imply that people will misuse an interface to accomplish something they shouldn&amp;#8217;t be, but more interfaces may result in users simply using the wrong entry point.)&lt;/li&gt;
		&lt;li&gt;learning curve on the part of users to figure out your APIs (fewer interfaces usually = better)&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;...and many others as well.  I think API designers use &amp;#8220;principles&amp;#8221; specifically as a hedge against these uncertainties:  &amp;#8220;I might be wrong in some of my assumptions, but at least by following this pattern I&amp;#8217;m requiring someone else to be wrong along with me.&amp;#8221;  That seems like somewhat reasonable, if impure, logic.&lt;/p&gt;</description>
      <pubDate>Tue, 20 Dec 2005 08:23:59 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:</guid>
      <link>http://blog.moertel.com/articles/2005/12/08/cost-reducing-interfaces-should-be-the-focus#comment-93</link>
    </item>
    <item>
      <title>"Cost-reducing interfaces should be the focus" by Shalabh</title>
      <description>&lt;p&gt;Great point. Howerver the problem is &lt;strong&gt;how&lt;/strong&gt; to determine the cost. It if often difficult, if not impossible, to get a bunch of users to try out your API and say &amp;#8216;yes this is easy&amp;#8217; or &amp;#8216;no this is too complex&amp;#8217; etc.&lt;/p&gt;


	&lt;p&gt;What techniques do you employ to achive the optimal solution?&lt;/p&gt;</description>
      <pubDate>Wed, 14 Dec 2005 22:20:48 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:</guid>
      <link>http://blog.moertel.com/articles/2005/12/08/cost-reducing-interfaces-should-be-the-focus#comment-92</link>
    </item>
    <item>
      <title>"Cost-reducing interfaces should be the focus" by Tom Moertel</title>
      <description>&lt;p&gt;John, thanks for your comment.&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;However, in terms of cost you&amp;#8217;re missing a critical factor: context.&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;I don&amp;#8217;t follow your logic here.  Keeping the focus on cost ensures that context &lt;em&gt;will&lt;/em&gt; be considered.  How else do we arrive at some understanding of an interface&amp;#8217;s cost if not through consideration of who will be affected by the interface and how those people will be affected?&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;Who defines the cost? In the general case, that&amp;#8217;s a non-trivial problem.&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;That&amp;#8217;s okay. We don&amp;#8217;t need a perfect definition of cost to benefit from a cost-focused approach.  Just &lt;em&gt;thinking about cost&lt;/em&gt; provides benefits by itself.&lt;/p&gt;


	&lt;p&gt;Right now, too many library designers don&amp;#8217;t think about cost.  Instead, they apply higher design &amp;#8220;principles&amp;#8221; like DRY, YAGNI, or the 80/20 rule, or seek to make their interfaces minimal or humane, without due consideration of whether these principles or interface ideals make sense for the situation.&lt;/p&gt;


	&lt;p&gt;That&amp;#8217;s why cost is important.  It always makes sense, and it helps us put everything else in perspective.&lt;/p&gt;


	&lt;p&gt;Cheers.&lt;/p&gt;</description>
      <pubDate>Mon, 12 Dec 2005 14:05:18 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:</guid>
      <link>http://blog.moertel.com/articles/2005/12/08/cost-reducing-interfaces-should-be-the-focus#comment-91</link>
    </item>
    <item>
      <title>"Cost-reducing interfaces should be the focus" by John D. Mitchell</title>
      <description>&lt;p&gt;I completely concur with forest / trees point (see my blog entry for more (linked above)).  However, in terms of cost you&amp;#8217;re missing a critical factor: context.  It comes down to a simple question: Who defines the cost?  In the general case, that&amp;#8217;s a non-trivial problem. That&amp;#8217;s why &amp;#8220;creeping featuritis&amp;#8221; is so deadly in the long term (look at the evolution of C++
and Java) and why design by committee results in completely wretched outcomes (witness all of the creation that the C++ &amp;#8220;standardization&amp;#8221; committee did).&lt;/p&gt;</description>
      <pubDate>Sat, 10 Dec 2005 13:05:02 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:</guid>
      <link>http://blog.moertel.com/articles/2005/12/08/cost-reducing-interfaces-should-be-the-focus#comment-90</link>
    </item>
  </channel>
</rss>
