<?xml version="1.0" encoding="windows-1252"?>
<node id="371065" title="Re: HTML - sharing design and logic" created="2004-07-01 08:59:58" updated="2005-03-25 09:26:01">
<type id="11">
note</type>
<author id="326467">
dfaure</author>
<data>
<field name="doctext">
&lt;blockquote&gt;&lt;i&gt;I think it is never trully possible to seperate design and logic
&lt;/i&gt;&lt;/blockquote&gt;

&lt;p&gt;IMHO, you should take care to differentiate applicative-logic and GUI-logic, and consider 3 abstraction layers:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;HTML-Template data, aka GUI elements, look-and-feel, skins, whatever you call it.&lt;/li&gt;
&lt;li&gt;GUI-logic, tiny code elements, totally dedicated to data appearance. There you'll use HTML::Template modules or equivalent to handle HTML data from above layer. Taking an OO-approach, you may define here a "widgets" hierarchy of specialized objects.&lt;/li&gt;
&lt;li&gt;Lastly, You'll have applicative-logic dedicated to manage applicative-datas and providing them to users through the help of above layer functionnalities.&lt;/li&gt;
&lt;/ol&gt;
&lt;readmore&gt;
&lt;code&gt;
                   +-------+
                   | Users |
                   +-------+
                       ^
                       |
                       v
+------------+   +-----------+
| HTML-Datas |--&gt;| GUI-logic |
+------------+   +-----------+
                       ^
                       |
                       v
             +-------------------+
             | Applicative-logic |
             +-------------------+
                       ^
                       |
                       v
                   +-------+
                   | Datas |
                   +-------+
&lt;/code&gt;
&lt;/readmore&gt;
&lt;p&gt;&lt;b&gt;Pro:&lt;/b&gt; Design and logic &lt;u&gt;are&lt;/u&gt; separated.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Cons:&lt;/b&gt; You'll have to stricly follow the rules of responsability separation when developping the differents layers. Anyway, you'll have a bit more code to produce and support all caveats involvde (more code =&gt; more bugs =&gt; more tests required =&gt; less time).&lt;/p&gt;

&lt;p&gt;This kind of slicing gives you the basements to build applications decribed as 'Model-View-Controller' in Design-Pattern litteracy.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Updated:&lt;/b&gt;corrected some typos and added schematic.&lt;/p&gt;

&lt;div class="pmsig"&gt;&lt;div class="pmsig-326467"&gt;
&lt;p&gt;____&lt;br/&gt;
[id://262941|HTH], Dominique&lt;br/&gt;
&lt;font size='1'&gt;&lt;i&gt;My two favorites:&lt;br/&gt;
If the only tool you have is a hammer, you will see every problem as a nail. --Abraham Maslow&lt;br/&gt;
Bien faire, et le faire savoir...&lt;/i&gt;&lt;/font&gt;&lt;/p&gt;

&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
371039</field>
<field name="parent_node">
371039</field>
</data>
</node>
