3 ms·
The other matter of style is whether the order of the code matches the order in which the user interacts with it. The three steps in user experience order:
by DougBTX 17y ago
The other matter of style is whether the order of the code matches the order in which the user interacts with it.
The three steps in user experience order:
first: a form to accept input,
second: a link to click
third: a printout of the input
Here are the orders used in code:
Ruby+sinatra: third, first, second
arc version 1: third, second, first (original)
arc version 2: second, third, first (May 2009)
Haskell+custom: first, second, third
Interesting results, I think Haskell wins here. Though technically it fails the challenge (the arc version 2 example fails too) since the supporting library was written after the challenge was considered by the author of the example.
- draegtun 17y agoThe Perl+Continuity solution also uses "first, second & third" style and does it nicely without sessions and adheres to challenge by being an established library: http://arclanguage.org/item?id=805 http://arclanguage.org/item?id=805 Here is a version using the HTML::AsSubs module: use Continuity; use HTML::AsSubs; Continuity->new->loop; # This starts the webserver sub main { my $request = shift; my $p = 'foo'; $request->print( aform( $p )->as_HTML ); my $foo = $request->next->param( $p ); $request->print( w_link()->as_HTML ); $request->next->print( "You said: $foo" ); } sub aform { form( input( { type => 'text', name => $_[0] } ), input( { type => 'submit'} ) ); } sub w_link { a( { href => '.' }, 'Click Here' ) }