<br><br><div class="gmail_quote">On Fri, Aug 5, 2011 at 3:29 PM, Allen Wirfs-Brock <span dir="ltr"><<a href="mailto:allen@wirfs-brock.com">allen@wirfs-brock.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div style="word-wrap:break-word"><div><div class="im"><div>I think the Class function I suggest above could be an answer.  But exploring this was my motivation in writing a significant amount of code using my pattern.  I personally didn't find it awkward, error-prone, or to present any readability issues.  But that is all subjective.  If somebody should translated that corpus into class declarations we can do a side-by-side comparison of readability.</div>

</div></div></div></blockquote><div><br></div><div>Brilliant idea. I started doing that <a href="https://github.com/munificent/ESnext-experiments">here</a>. Example:</div><div><br></div><div><pre><div class="line" id="LC60">

  <span class="c1">// Define a non-constructible superclass that provides some Smalltalk-like</span></div><div class="line" id="LC61">  <span class="c1">// conventions.</span></div><div class="line" id="LC62">  <span class="kr">class</span> <span class="nx">AbstractClass</span> <span class="p">{</span></div>

<div class="line" id="LC63">    <span class="nx">name</span> <span class="o">=</span> <span class="s2">"AbstractClass"</span><span class="p">;</span></div><div class="line" id="LC64"><br></div><div class="line" id="LC65">

    <span class="nx">get</span> <span class="kr">class</span><span class="p">()</span> <span class="p">{</span> <span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">constructor</span><span class="p">;</span> <span class="p">}</span></div>

<div class="line" id="LC66"><br></div><div class="line" id="LC67">    <span class="nx">error</span><span class="p">(</span><span class="nx">message</span><span class="p">)</span> <span class="p">{</span> <span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="nx">message</span><span class="p">);</span> <span class="p">}</span></div>

<div class="line" id="LC68"><br></div><div class="line" id="LC69">    <span class="nx">subclassResponsibility</span><span class="p">()</span> <span class="p">{</span> <span class="k">this</span><span class="p">.</span><span class="kr">class</span><span class="p">.</span><span class="nx">subclassResponsibility</span><span class="p">();</span> <span class="p">}</span></div>

<div class="line" id="LC70">    <span class="nx">shouldNotImplement</span><span class="p">()</span> <span class="p">{</span> <span class="k">this</span><span class="p">.</span><span class="kr">class</span><span class="p">.</span><span class="nx">shouldNotImplement</span><span class="p">();</span> <span class="p">}</span></div>

<div class="line" id="LC71"><br></div><div class="line" id="LC72">    <span class="nx">errorSubscriptBounds</span><span class="p">(</span><span class="nx">index</span><span class="p">)</span> <span class="p">{</span></div>

<div class="line" id="LC73">      <span class="k">this</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="s2">"subscript is out of bounds: "</span> <span class="o">+</span> <span class="nx">index</span><span class="p">);</span></div>

<div class="line" id="LC74">    <span class="p">}</span></div><div class="line" id="LC75"><br></div><div class="line" id="LC76">  <span class="kr">class</span><span class="o">:</span></div><div class="line" id="LC77">    <span class="nx">subclassResponsibility</span><span class="p">()</span> <span class="p">{</span></div>

<div class="line" id="LC78">      <span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">name</span> <span class="o">+</span> <span class="s2">" did not implemente an abstract method."</span><span class="p">);</span></div>

<div class="line" id="LC79">    <span class="p">}</span></div><div class="line" id="LC80"><br></div><div class="line" id="LC81">    <span class="nx">shouldNotImplement</span><span class="p">()</span> <span class="p">{</span></div>

<div class="line" id="LC82">      <span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">name</span> <span class="o">+</span> <span class="s2">" should not implemented by a method"</span><span class="p">);</span></div>

<div class="line" id="LC83">    <span class="p">}</span></div><div class="line" id="LC84">  <span class="p">}</span></div></pre></div><div>- bob</div><div><br></div></div>