<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Just a Thought...: Tag orm</title>
    <link>http://bloritsch.d-haven.net/articles/tag/orm</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Random thoughts</description>
    <item>
      <title>Naked Objects, Point - Counterpoint</title>
      <description>&lt;p&gt;The &lt;a href="http://www.pragprog.com/"&gt;Pragmatic Programmer&lt;/a&gt;  folks have a new book out called &lt;a href="http://www.pragprog.com/titles/dhnako/domain-driven-design-using-naked-objects"&gt;Domain-Driven Design Using Naked Objects&lt;/a&gt;  which caught my attention.  The title caught my attention, and I figured the author was using Naked Objects in the same vein as Jamie Oliver as &amp;#8220;The Naked Chef&amp;#8221; (old series on Food Network).  Essentially, the ingredients are used to their full potential, complimenting each other without the heavy use of spice.  So I decided to do some research on where this came from.  My suspicions were confirmed, and made even more sense when I found the original thesis came from someone at Trinity College, Dublin.&lt;/p&gt;


	&lt;p&gt;I found the original thesis by Richard Pawson entitled &lt;a href="http://www.nakedobjects.org/downloads/Pawson%20thesis.pdf"&gt;Naked objects&lt;/a&gt;  where he details the principles behind the concept.  The thesis is very readable, as theses go.  It is broken up into an introduction, a case study, guiding principles, etc.  What I found more interesting was the forward written by the pioneer of the &lt;span class="caps"&gt;MVC&lt;/span&gt; pattern, Trygve Reenskaug.  The concept of Naked Objects isn&amp;#8217;t exactly new, and it should be lauded for its intent of getting back to the proper intent of object oriented design and programming.  Of course, as a technology, and as some of the design constraints of naked objects, the thesis is not without detractors.  For example a short paper by Larry Constantine called &lt;a href="http://foruse.com/articles/nakedobjects.pdf"&gt;The Emperor Has No Clothes: Naked Objects Meet the Interface&lt;/a&gt; .&lt;/p&gt;


	&lt;p&gt;The true value in something like Naked Objects is to get you to adjust the way you are thinking.  The main concept is to build the complete logic of the system using a finite set of domain objects.  The framework is designed to take care of database persistence and user interface.  According to the forward in the thesis, the spirit behind &lt;span class="caps"&gt;MVC&lt;/span&gt; is that each view is mapped to only one object, although each object might be mapped to many views.  The controller is responsible for mapping the events of the view (inputs, etc.) to the domain model.  Essentially the domain model (or model) uses views for output and controllers for input.  This is different from the way it was originally described to me and I originally understood the pattern.  Pawson argues that the framework can generate the user interface views and controllers automatically.  Further advances in the concept also automatically maps the domain model to a relational database using &lt;a href="https://www.hibernate.org/"&gt;Hibernate&lt;/a&gt; .&lt;/p&gt;


	&lt;p&gt;The software developer side of me likes this concept.  It&amp;#8217;s less plumbing to worry about.  I don&amp;#8217;t have to know how to code a user interface.  I can get my work done quicker.  However, the user interface design side of me loathes the concept because the user interface (admittedly by Pawson) is not easily grasped without training, nor is it particularly accessible.  The architect in me is thinking about how I can have my cake and eat it too.  Ignoring the problem of database mapping for a moment, the real challenge is in the view/controller (VC) layer.  Pawson sites arguments from advocates of Object Oriented User Interface (OOUI) design that there is only one true correct way of representing an object.  Yet turns around and presents two: an icon to represent the object and a dialog box to represent the content in the object.  In my own project I am working on now, there are at least two representations of every object: the view in a list, and the view of the full content of the object.  Nevertheless, there still remains concepts I can leverage.&lt;/p&gt;


	&lt;p&gt;In some respects &lt;a href="http://wicket.apache.org"&gt;Wicket&lt;/a&gt;  would be an ideal candidate for dynamic generation of VC code.  Or at the very least, due to its attempt to treat the view layer in an object oriented manner, some extensions to the application can dynamically generate the controller side.  I have some reservations about pursuing that too far at the moment.  The real conundrum is in the presentation layer.  Managing information and behavior is something that object oriented languages are designed to handle.  It is right and good to take advantage of the features of your language to properly model the business domain.  However, representing that same information to the user in a way that makes sense to the user is a completely different discipline.  I can argue against the principles in &lt;span class="caps"&gt;OOUI&lt;/span&gt; till I&amp;#8217;m blue in the face, but that doesn&amp;#8217;t solve the fundamental problem.&lt;/p&gt;


	&lt;p&gt;What we need is a way for the programmers to create the functionally complete object oriented domain model, while your user interface specialists concentrate on their responsibility.  While frameworks such as Wicket have tried to address that very problem, it is my personal opinion that they fall a little short.  I don&amp;#8217;t think the fault lies with Wicket.  The fault lies within the current set of &lt;span class="caps"&gt;W3C&lt;/span&gt; standards and differing levels of browser compliance.  The &lt;span class="caps"&gt;W3C&lt;/span&gt; is still stuck on a model that prefers static information.  If the &lt;span class="caps"&gt;W3C&lt;/span&gt; were to truly pursue a model where the user interface layer is bound to certain objects and the browser makes calls to the server to render these objects we might have a better solution.  We&amp;#8217;ve already started down this path with &lt;span class="caps"&gt;AJAX&lt;/span&gt; and the myriad of Javascript frameworks to make this work.  Needless to say that there is a lot of future work that has to be done in order to truly see a synergy from functionally complete domain models and an object oriented user interfaces.&lt;/p&gt;


The goal of such an endeavor should be to allow user interface designers these freedoms:
	&lt;ul&gt;
	&lt;li&gt;Create the representations of the objects as they see fit&lt;/li&gt;
		&lt;li&gt;Create the rules of how to select the correct view from the different possibilities.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;The controller logic should be built into the browser already, in terms of invoking the domain model (or representations of a remote object).&lt;/p&gt;


	&lt;p&gt;While I&amp;#8217;m on the subject of Naked Objects and domain models, I&amp;#8217;d like to make a minor rant on Object/Relational Mapping tools.  One of the problems is that &lt;span class="caps"&gt;ORM&lt;/span&gt; tools tend to require accessor and mutator methods (getters and setters) for every field that is going to be persisted to the database.  While you are &lt;em&gt;technically&lt;/em&gt; encapsulating the internal state of the object, in 99.44% of the cases there is no difference in using the accessor and mutator methods and directly accessing the underlying attributes of the class.  In a properly designed object, you only need to expose information via accessors that the user is allowed to see, and you only provide mutator methods for what the user is allowed to change.  &lt;span class="caps"&gt;ORM&lt;/span&gt; tools require you to violate those principles if you want to persist the information down to the database.  Some &lt;span class="caps"&gt;ORM&lt;/span&gt; tools (ActiveRecord) generates these accessors and mutators dynamically for you.  That&amp;#8217;s great for convenience, but terrible for a properly designed domain model.  For the time being, there really is no alternative unless you write the &lt;span class="caps"&gt;ORM&lt;/span&gt; layer yourself.  Not recommended if you can help it.&lt;/p&gt;</description>
      <pubDate>Fri, 18 Dec 2009 14:27:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:c5e2d08d-66ce-4de7-b918-1b00ed550077</guid>
      <author>Berin Loritsch</author>
      <link>http://bloritsch.d-haven.net/articles/2009/12/18/naked-objects-point-counterpoint</link>
      <category>naked</category>
      <category>objects</category>
      <category>orm</category>
      <category>wicket</category>
      <category>domain</category>
      <category>model</category>
      <category>design</category>
      <category>user</category>
      <category>interface</category>
    </item>
  </channel>
</rss>
