<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
    <channel>
        <title>Spreadsheets - Blogs at Near Infinity</title>


        <link>http://www.nearinfinity.com/blogs/</link>
        <description>Employee Blogs</description>
        <language>en</language>
        <copyright>Copyright 2011</copyright>
        <lastBuildDate>Thu, 10 May 2007 17:29:59 -0500</lastBuildDate>
        <generator>http://www.sixapart.com/movabletype/</generator>
        <docs>http://www.rssboard.org/rss-specification</docs>
        
        <item>
            <title>Client vs. server: who does what in an online spreadsheet?</title>
            <description><![CDATA["Data elements" are the focus of Section <a href="http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm#sec_5_2_1">5.2.1</a> of Dr. Fielding's dissertation. I think the focus is who does how much work to render the data. He lists three options: mostly server, mixed client &amp; server, and mostly client:

<code id="bigun" class="prettyprint">                
&nbsp;Server&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Client
|----------------------------------------------------------------------|
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|
&nbsp;1.&nbsp;Fixed&nbsp;format&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2.&nbsp;encapsulated&nbsp;data&nbsp;&amp;&nbsp;code&nbsp;&nbsp;&nbsp;&nbsp;3.&nbsp;raw&nbsp;data&nbsp;&amp;&nbsp;metadata
&nbsp;&nbsp;&nbsp;&nbsp;(jpeg)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(json,&nbsp;javascript)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(html&nbsp;&lt;img&gt;&nbsp;tag?)
</code>
<p>
This is an important decision for an online spreadsheet. Should the server send only literal values (option one)? Should the client evaluate functions and resolve references? (option two)?

</p><h3>Option 1:</h3>
<p>&nbsp;&nbsp;&nbsp;&nbsp;pro: parsing cell values into a tree and traversing it is tricky. Writing it once in Java seems like a reasonable approach.
</p><p>&nbsp;&nbsp;&nbsp;&nbsp;con: client has no idea which cells are related to each other. That would really complicate features like copying and pasting cell references.

</p><h3>Option 2:</h3>
<p>&nbsp;&nbsp;&nbsp;&nbsp;con: reimplement much of cell parsing &amp; traversal in Javascript. Using Rhino to test it outside a browser mitigates this a little.
</p><p>&nbsp;&nbsp;&nbsp;&nbsp;pro: client knows which cells are related.

</p><h3>Option 3:</h3>
<p>&nbsp;&nbsp;&nbsp;&nbsp;con: no idea how to apply this approach for a spreadsheet.

</p><p>I chose option two. Eventually the client will probably need to work directly with cell references. Better to get that work out of the way ahead of time. Not all of the logic needs to be rewritten. Some of it is only needed on one side:

</p><h3>common:</h3>
<ul>
<li>build parse tree from cell values
</li><li>iterate over parse tree
</li></ul>

<h3>server specific:</h3>
<ul>
<li>update reference values:  A1 =&gt; B1, $G3 =&gt; $G4
</li><li>collapse the parse tree back into a flat string
</li></ul>

<h3>client specific:</h3>
<ul>
<li>resolve reference values (A1 = 123.45, G3 = A1 = 123.45). 
</li><li>evaluate functions (=SUM(G3,A1) =&gt; 246.9).
</li></ul>
<p>I didn't expect so many neat challenges. Even the prototype implementation needed parsing, recursion, evaluating simple math expressions, tree traversal, base10 &amp; base26 conversion, and more. But all that is meat for another post.</p>]]></description>
            <link>http://www.nearinfinity.com/blogs/seth_schroeder/client_vs_server_who_does.html</link>
            <guid>http://www.nearinfinity.com/blogs/seth_schroeder/client_vs_server_who_does.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">Spreadsheets</category>
            
            
            <pubDate>Thu, 10 May 2007 17:29:59 -0500</pubDate>
        </item>
        
    </channel>
</rss>

