<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    On 06/17/2014 02:15 PM, Torstein Saltvedt wrote:<br>
    <blockquote
cite="mid:CAD-PwEuaj4TF0-pEf7sZQaGpDDRxe_GuvRAgfL=Udkj1ucOtrg@mail.gmail.com"
      type="cite">
      <div dir="ltr">But here you place the entire logic and
        presentation of the application in a single 150 lines of code
        long function. 
        <div><br>
        </div>
        <div>It reminds me about the awful SQL/HTML spaghetti I wrote
          when I first started learning programming with PHP. And while
          the Ur/Web code is probably totally fine with all it's fancy
          type-checking and whatnot, it looks <i>really</i> <i>scary</i> to
          my object oriented eyes.</div>
      </div>
    </blockquote>
    <br>
    IMO, this example needs so little code that splitting it into
    components in separate files could actually impede maintainability.<br>
    <br>
    As an experiment, I've put up a version, at <a
      href="http://www.impredicative.com/ur/todomvc/">the same URL</a>,
    splitting the HTML styling into a separate module.  What do you
    think?<br>
    <br>
    <blockquote
cite="mid:CAD-PwEuaj4TF0-pEf7sZQaGpDDRxe_GuvRAgfL=Udkj1ucOtrg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>What about keeping code DRY?</div>
      </div>
    </blockquote>
    <br>
    Where in particular are you seeing undesirable repetition?<br>
    <br>
    <blockquote
cite="mid:CAD-PwEuaj4TF0-pEf7sZQaGpDDRxe_GuvRAgfL=Udkj1ucOtrg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>Separation of concerns?</div>
      </div>
    </blockquote>
    <br>
    This one is too broad for me to comment on.<br>
    <br>
    <blockquote
cite="mid:CAD-PwEuaj4TF0-pEf7sZQaGpDDRxe_GuvRAgfL=Udkj1ucOtrg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>Preventing too many levels of nesting?</div>
      </div>
    </blockquote>
    <br>
    That's in the eye of the beholder, I guess!<br>
    <br>
    <blockquote
cite="mid:CAD-PwEuaj4TF0-pEf7sZQaGpDDRxe_GuvRAgfL=Udkj1ucOtrg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>Keeping functions short and testable?</div>
      </div>
    </blockquote>
    <br>
    I don't generally think of this criterion as too important in
    languages with expressive static type systems.  I don't do
    systematic testing, and I feel like most such testing in Ruby, etc.
    is just finding type errors!  (Keep in mind that type systems can
    capture much stronger properties than in mainstream languages, such
    as Ur/Web's use of types to catch bad links, schema-incorrect
    database accesses, the equivalents of "wrong ID errors" in
    imperative JavaScript code, etc.)<br>
    <br>
    <blockquote
cite="mid:CAD-PwEuaj4TF0-pEf7sZQaGpDDRxe_GuvRAgfL=Udkj1ucOtrg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>Encapsulation?</div>
      </div>
    </blockquote>
    <br>
    Ur/Web's encapsulation facilities are IMO far superior to those in
    Ruby on Rails, with the possibility for module-local database
    tables, encapsulated GUI widgets whose private state can't be messed
    with even by other Ur/Web code that contains deliberate mistakes,
    etc.  This example is just too small to call for serious use of
    module structure.<br>
    <br>
    <blockquote
cite="mid:CAD-PwEuaj4TF0-pEf7sZQaGpDDRxe_GuvRAgfL=Udkj1ucOtrg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>If you wanted to change the TodoMVC implementations of the
          mainstream javascript frameworks to use persistence you would
          only need to change the models. The rest of the application
          would stay the same. (Let's just ignore the actual REST API.)</div>
        <div><br>
        </div>
        <div>I know it is asking a lot, but I would love to see how this
          would be refactored to use Ur/Webs database persistence.</div>
      </div>
    </blockquote>
    <br>
    Done, as another part of the same demo-set.  The todo list is
    written to the remote database every 5 seconds, and refreshing the
    page starts from the current database contents.  I started from the
    version with a separate module for HTML styling, and the diff is
    under 30 lines of code, including a small extraction of a reusable
    function that might also make sense for the original version.<br>
  </body>
</html>