<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://pkp-www.lib.sfu.ca:8084/wiki/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://pkp-www.lib.sfu.ca:8084/wiki/index.php?title=Data_Access_Objects_(DAO)&amp;feed=atom&amp;action=history</id>
		<title>Data Access Objects (DAO) - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://pkp-www.lib.sfu.ca:8084/wiki/index.php?title=Data_Access_Objects_(DAO)&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://pkp-www.lib.sfu.ca:8084/wiki/index.php?title=Data_Access_Objects_(DAO)&amp;action=history"/>
		<updated>2013-05-18T11:45:49Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.20.5</generator>

	<entry>
		<id>http://pkp-www.lib.sfu.ca:8084/wiki/index.php?title=Data_Access_Objects_(DAO)&amp;diff=2010&amp;oldid=prev</id>
		<title>Jerico.dev: Removed the &quot;two different accessor&quot; approach for dependent objects as it created too much confusion in practice. Better explain and justify the subclassing approach.</title>
		<link rel="alternate" type="text/html" href="http://pkp-www.lib.sfu.ca:8084/wiki/index.php?title=Data_Access_Objects_(DAO)&amp;diff=2010&amp;oldid=prev"/>
				<updated>2011-03-21T17:57:00Z</updated>
		
		<summary type="html">&lt;p&gt;Removed the &amp;quot;two different accessor&amp;quot; approach for dependent objects as it created too much confusion in practice. Better explain and justify the subclassing approach.&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr style='vertical-align: top;'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 17:57, 21 March 2011&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 96:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 96:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If you decide that you cannot serve all use cases by the same set of dependent objects then you can use one of the following strategies to break the dependency chain in a well-defined way:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If you decide that you cannot serve all use cases by the same set of dependent objects then you can use one of the following strategies to break the dependency chain in a well-defined way:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=== &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Use-case specific DAO methods &lt;/del&gt;===&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=== &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Lazy Load &lt;/ins&gt;===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;We &lt;/del&gt;can &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;create two different DAO-methods, one that retrieves &lt;/del&gt;a &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;fully populated object &lt;/del&gt;and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;another that only retrieves an object with basic values set&lt;/del&gt;. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;This is often the cheapest&lt;/del&gt;, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;simplest and easiest to maintain solution&lt;/del&gt;. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Of course this means that we introduce &lt;/del&gt;a &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;certain dependency between the controller &lt;/del&gt;and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;the DAO but &lt;/del&gt;if &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;the methods have at least some potential for re-use then this implementation &lt;/del&gt;is &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;often &lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;best. Code duplication should be avoided by sharing re-usable SQL snippets and object population code internally &lt;/del&gt;between &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;different accessors.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;The simplest solution often is lazy load. It &lt;/ins&gt;can &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;provide &lt;/ins&gt;a &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;good compromise between a simple class design &lt;/ins&gt;and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;good performance&lt;/ins&gt;. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Mind premature optimization&lt;/ins&gt;, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;though&lt;/ins&gt;. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Using lazy load is &lt;/ins&gt;a &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;performance optimization technique &lt;/ins&gt;and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;doesn't make sense &lt;/ins&gt;if &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;there &lt;/ins&gt;is &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;no visible performance impact by instantiating dependent objects right away!! Otherwise &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;pattern introduces unnecessary coupling &lt;/ins&gt;between &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;the domain &lt;/ins&gt;object and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;other DAOs which increases maintenance cost &lt;/ins&gt;and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is &lt;/ins&gt;to &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;be avoided&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Example: Implement a DAO method that retrieves an Author &lt;/del&gt;object &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;with it's user group populated &lt;/del&gt;and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;another one that leaves the Author's user group null. The former calls the latter &lt;/del&gt;and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;only adds the user group. We can add an assertion &lt;/del&gt;to &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;the DO, i.e. in this case Author::getUserGroup() that makes sure that the accessor is never called when the field has not been populated&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;=== Lazy Load ===&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;We can &lt;/del&gt;initialize (parts of) an object at runtime when needed by depending on another DAO to retrieve the linked object when needed, i.e.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Lazy load means to &lt;/ins&gt;initialize (parts of) an object at runtime when needed by &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;directly &lt;/ins&gt;depending on another DAO to retrieve the linked object when needed, i.e.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160; class Chapter {&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160; class Chapter {&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 113:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 109:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160; }&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160; }&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;This makes sense when loading dependencies is expensive and they are not very often used. The pattern introduces close coupling between the domain object and other DAOs which potentially increases maintenance cost.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=== &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;DAO inheritance &lt;/del&gt;===&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=== &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Polymorphism &lt;/ins&gt;===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;The most complex solution is that we can introduce subclasses so that we can use &lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;general concept of an entity &lt;/del&gt;in &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;use &lt;/del&gt;cases &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;where we require less data and &lt;/del&gt;only &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;instantiate &lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;the more complex, specialized (and expensive) concept of an entity when &lt;/del&gt;really &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;needed&lt;/del&gt;. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;See the &lt;/del&gt;inheritance &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;mapper design pattern above for &lt;/del&gt;that &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;case&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;If &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;dependent object is not required &lt;/ins&gt;in &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;all &lt;/ins&gt;cases &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;then introducing a subclass may be another possible solution. This solution is &lt;/ins&gt;only &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;a good one if &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;subclass &lt;/ins&gt;really &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;makes sense as a separate conceptual entity&lt;/ins&gt;. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Inheritance is a precious good because there can only be one &lt;/ins&gt;inheritance &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;hierarchy. If you inherit from another class be aware &lt;/ins&gt;that &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;you prevent others from doing so later in cases that may better justify inheritance. Therefore you should never introduce sub-classes just to improve performance, use lazy load instead! Always make the &amp;quot;natural language test&amp;quot; to validate your inheritance approach, i.e. saying &amp;quot;subclass abc '''is''' a parent class xyz&amp;quot; should make sense in natural language&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Please make sure, though, &lt;/del&gt;that the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;entities really implement a semantic concept that makes sense in &lt;/del&gt;&amp;quot;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;natural language&lt;/del&gt;&amp;quot;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, i.e. a concept that is not only introduced for performance but immediately makes sense to &lt;/del&gt;those &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;who read &lt;/del&gt;the code and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;those who use &lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;application&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;This also means &lt;/ins&gt;that the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;current specializations of Submissions into &lt;/ins&gt;&amp;quot;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;ReviewerSubmissions&lt;/ins&gt;&amp;quot; &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;or &amp;quot;AuthorSubmissions&amp;quot; with their corresponding DAOs are anti-patterns - you shouldn't reproduce &lt;/ins&gt;those&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;. They couple &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;DAO to specific controller transactions, break encapsulation and good separation of concerns, produce duplicate &lt;/ins&gt;code&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;, do not improve performance &lt;/ins&gt;and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;not even reduce complexity. They could be implemented much more elegantly with &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;other design options outlined above&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;The current specializations of Submissions into &amp;quot;ReviewerSubmissions&amp;quot; or &amp;quot;AuthorSubmissions&amp;quot; with their corresponding DAOs are anti-patterns - you shouldn't reproduce those! They couple &lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;DAO to specific controller transactions&lt;/del&gt;, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;break encapsulation &lt;/del&gt;and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;good separation &lt;/del&gt;of &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;concerns, produce duplicate code, do not improve performance and not even reduce complexity&lt;/del&gt;. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;They could be implemented much more elegantly with &lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;other &lt;/del&gt;design &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;options outlined &lt;/del&gt;above.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Subclassing allows us to only instantiate &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;more complex&lt;/ins&gt;, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;specialized (&lt;/ins&gt;and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;expensive) concept &lt;/ins&gt;of &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;an entity when really needed&lt;/ins&gt;. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;See &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;inheritance mapper &lt;/ins&gt;design &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;pattern &lt;/ins&gt;above &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;on how to implement a DAO for subclasses&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;= Common DAO Design Errors =&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;= Common DAO Design Errors =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jerico.dev</name></author>	</entry>

	<entry>
		<id>http://pkp-www.lib.sfu.ca:8084/wiki/index.php?title=Data_Access_Objects_(DAO)&amp;diff=1964&amp;oldid=prev</id>
		<title>Jerico.dev: Added a rule for methods that change data.</title>
		<link rel="alternate" type="text/html" href="http://pkp-www.lib.sfu.ca:8084/wiki/index.php?title=Data_Access_Objects_(DAO)&amp;diff=1964&amp;oldid=prev"/>
				<updated>2011-03-02T00:01:42Z</updated>
		
		<summary type="html">&lt;p&gt;Added a rule for methods that change data.&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr style='vertical-align: top;'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 00:01, 2 March 2011&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 59:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 59:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The first question to answer is where to put your method. You can potentially query objects in both directions of the relation - e.g. you can return an Author object with all Chapters of that author as dependent objects or you can return a Chapter object with all authors of that chapter as dependent objects.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The first question to answer is where to put your method. You can potentially query objects in both directions of the relation - e.g. you can return an Author object with all Chapters of that author as dependent objects or you can return a Chapter object with all authors of that chapter as dependent objects.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The basic rule is: You always put your method into the DAO that corresponds to the return type of your &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;accessor&lt;/del&gt;. In other words: If you return chapters with authors as dependent objects then you put your method in the ChapterDAO, if you return authors with chapters as dependent objects then you put your method in the AuthorDAO.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The basic rule is&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;* For methods that read and return data&lt;/ins&gt;: You always put your method into the DAO that corresponds to the return type of your &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;method&lt;/ins&gt;. In other words: If you return chapters with authors as dependent objects then you put your method in the ChapterDAO, if you return authors with chapters as dependent objects then you put your method in the AuthorDAO&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;* For methods that change data (update, insert, delete): You always put your method into the DAO that corresponds to the main entity being updated&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== How to implement different types of relations? ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== How to implement different types of relations? ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jerico.dev</name></author>	</entry>

	<entry>
		<id>http://pkp-www.lib.sfu.ca:8084/wiki/index.php?title=Data_Access_Objects_(DAO)&amp;diff=1963&amp;oldid=prev</id>
		<title>Jerico.dev: Small improvements</title>
		<link rel="alternate" type="text/html" href="http://pkp-www.lib.sfu.ca:8084/wiki/index.php?title=Data_Access_Objects_(DAO)&amp;diff=1963&amp;oldid=prev"/>
				<updated>2011-03-01T06:58:29Z</updated>
		
		<summary type="html">&lt;p&gt;Small improvements&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr style='vertical-align: top;'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 06:58, 1 March 2011&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 37:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 37:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;To achieve this, the SubmissionFileDAO will delegate to one of the two concrete DAOs when one of its methods is being invoked. It identifies the right DAO either by inspecting the type of the object (on update/insert) or by querying the base table that contains some type indicator (on read access, e.g. genre in the case of the monograph/artwork file distinction).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;To achieve this, the SubmissionFileDAO will delegate to one of the two concrete DAOs when one of its methods is being invoked. It identifies the right DAO either by inspecting the type of the object (on update/insert) or by querying the base table that contains some type indicator (on read access, e.g. genre in the case of the monograph/artwork file distinction).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;To avoid unnecessary database queries the SubmissionFileDAO can also prepare data via outer joins over all class tables to be passed into the concrete DAOs. The methods of the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;delegates &lt;/del&gt;do not &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;necessarily &lt;/del&gt;correspond 1:1 to the methods &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;on &lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;public &lt;/del&gt;DAO &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;interface&lt;/del&gt;. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;See &lt;/del&gt;the separate inheritance hierarchies.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;To avoid unnecessary database queries the SubmissionFileDAO can also prepare data via outer joins over all class tables to be passed into the concrete DAOs. The methods of the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;concrete DAOs &lt;/ins&gt;do not &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;have to &lt;/ins&gt;correspond 1:1 to the methods &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;of &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;quot;orchestrating&amp;quot; &lt;/ins&gt;DAO. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;That's &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;reason why they are on &lt;/ins&gt;separate inheritance hierarchies &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;and why we distinguish between the SubmissionFileDAO and the AbstractSubmissionFileDAO in our example&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The inheritance mapper design does not prescribe a specific database design (see the three O/R mapping strategies above). We can use all common mapping techniques.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The inheritance mapper design does not prescribe a specific database design (see the three O/R mapping strategies above). We can use all common mapping techniques.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 43:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 43:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;You can use one of the concrete DAOs in your handler but only if you really want to deal with that specific domain object type. If you implement a special artwork file editing form for example it may make sense to use the ArtworkFileDAO directly. Most of the time access through the domain object DAO should be preferred, though, as it will deal with most cases and is easier to extend and maintain.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;You can use one of the concrete DAOs in your handler but only if you really want to deal with that specific domain object type. If you implement a special artwork file editing form for example it may make sense to use the ArtworkFileDAO directly. Most of the time access through the domain object DAO should be preferred, though, as it will deal with most cases and is easier to extend and maintain.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Please keep in mind that not all inheritance hierarchies are as simple as this one. There are usually multiple children to one parent class&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, otherwise inheritance wouldn't make sense after all&lt;/del&gt;. There is often not such a clear-cut design, then. You'll have to decide which parts of the inheritance hierarchy need their own &amp;quot;orchestrating&amp;quot; DAO managing &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;concrete &lt;/del&gt;DAOs. You can also nest &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;quot;orchestrating&amp;quot; &lt;/del&gt;DAOs into each other so that what is an &amp;quot;orchestrating&amp;quot; DAO on one level appears as a &amp;quot;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;concrete&lt;/del&gt;&amp;quot; DAO from the viewpoint of &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;an &amp;quot;orchestrating&amp;quot; DAO on &lt;/del&gt;a &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;higher level&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Please keep in mind that not all inheritance hierarchies are as simple as this one. There are usually multiple children to one parent class. There is often not such a clear-cut design, then. You'll have to decide which parts of the inheritance hierarchy need their own &amp;quot;orchestrating&amp;quot; DAO managing &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;quot;delegate&amp;quot; &lt;/ins&gt;DAOs. You can also nest DAOs into each other so that what is an &amp;quot;orchestrating&amp;quot; DAO on one level appears as a &amp;quot;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;delegate&lt;/ins&gt;&amp;quot; DAO from the viewpoint of a &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;parent class&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;= Mapping Relations Between Objects =&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;= Mapping Relations Between Objects =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jerico.dev</name></author>	</entry>

	<entry>
		<id>http://pkp-www.lib.sfu.ca:8084/wiki/index.php?title=Data_Access_Objects_(DAO)&amp;diff=1962&amp;oldid=prev</id>
		<title>Jerico.dev: typo</title>
		<link rel="alternate" type="text/html" href="http://pkp-www.lib.sfu.ca:8084/wiki/index.php?title=Data_Access_Objects_(DAO)&amp;diff=1962&amp;oldid=prev"/>
				<updated>2011-03-01T06:50:19Z</updated>
		
		<summary type="html">&lt;p&gt;typo&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr style='vertical-align: top;'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 06:50, 1 March 2011&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 23:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 23:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* How to map inheritance hierarchies (polymorphism) to database tables via DAOs?&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* How to map inheritance hierarchies (polymorphism) to database tables via DAOs?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* How to map relations between objects (composition/aggregation) to the database (one-to-many and many-to-many relations) via DAOs?&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* How to map relations between objects (composition/aggregation) to the database (one-to-many and many-to-many relations) via DAOs?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* How trade off performance (runtime, memory) against code re-use/maintainability and complexity?&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* How &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;to &lt;/ins&gt;trade off performance (runtime, memory) against code re-use/maintainability and complexity?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;= Polymorphism =&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;= Polymorphism =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jerico.dev</name></author>	</entry>

	<entry>
		<id>http://pkp-www.lib.sfu.ca:8084/wiki/index.php?title=Data_Access_Objects_(DAO)&amp;diff=1961&amp;oldid=prev</id>
		<title>Jerico.dev: Added 3NF</title>
		<link rel="alternate" type="text/html" href="http://pkp-www.lib.sfu.ca:8084/wiki/index.php?title=Data_Access_Objects_(DAO)&amp;diff=1961&amp;oldid=prev"/>
				<updated>2011-03-01T06:41:54Z</updated>
		
		<summary type="html">&lt;p&gt;Added 3NF&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr style='vertical-align: top;'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 06:41, 1 March 2011&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;= Normalization =&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Before anything else you should make sure that you have a good understanding of data normalization. The DAO pattern works best for normalized data which also is very good in avoiding data corruption.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Some good introductory articles are (in that order):&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;* http://databases.about.com/od/specificproducts/a/normalization.htm&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;* http://support.microsoft.com/kb/283878&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;* http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;= The DAO pattern =&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;= The DAO pattern =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 113:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 122:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;= Common DAO Design Errors =&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;= Common DAO Design Errors =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;== Data that is not normalized ==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;None of the reasons that may justify a deviation from third normal form (3NF) or similar normalization rules (e.g. big OLAP databases, no control over the database design, etc.) apply in our case. In an application like ours the advantages of 3NF outweigh by far the disadvantages.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Still we have got several examples of tables that are not correctly normalized. One example are tables that contain both, the file id and the submission id. The file id alone already implies a submission id (via the main submission file table in Oxx). Adding a submission id ''and'' a file id to a table means introducing the potential for data corruption. Experience shows that where data corruption is possible it will sooner or later occur. We already had plenty of bugs due to insufficiently normalized data.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== DOs that instantiate themselves via their corresponding DAO ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== DOs that instantiate themselves via their corresponding DAO ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jerico.dev</name></author>	</entry>

	<entry>
		<id>http://pkp-www.lib.sfu.ca:8084/wiki/index.php?title=Data_Access_Objects_(DAO)&amp;diff=1960&amp;oldid=prev</id>
		<title>Jerico.dev: improve layout</title>
		<link rel="alternate" type="text/html" href="http://pkp-www.lib.sfu.ca:8084/wiki/index.php?title=Data_Access_Objects_(DAO)&amp;diff=1960&amp;oldid=prev"/>
				<updated>2011-03-01T05:44:05Z</updated>
		
		<summary type="html">&lt;p&gt;improve layout&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr style='vertical-align: top;'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 05:44, 1 March 2011&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 116:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 116:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== DOs that instantiate themselves via their corresponding DAO ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== DOs that instantiate themselves via their corresponding DAO ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;We had cases where a DO &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;instantiates &lt;/del&gt;itself via its own DAO and copying this code across the inheritance hierarchy. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Don&lt;/del&gt;'&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;t confuse this with &lt;/del&gt;the above lazy-load pattern&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;. &lt;/del&gt;While it &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;is &lt;/del&gt;ok that a domain object lazy-loads other objects, it's &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;usually &lt;/del&gt;not ok that a domain object instantiates itself.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;We had cases where a DO &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;instantiated ''&lt;/ins&gt;itself&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'' &lt;/ins&gt;via its own DAO and copying this code across the inheritance hierarchy. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;This is &lt;/ins&gt;'&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'not'' the same as &lt;/ins&gt;the above lazy-load pattern&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;! &lt;/ins&gt;While &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;under some circumstances &lt;/ins&gt;it &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;may be &lt;/ins&gt;ok that a domain object lazy-loads other objects &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;via their DAOs&lt;/ins&gt;, it's not ok that a domain object instantiates itself &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;via its own DAO&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Compositions that are not part of the concept of an object ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Compositions that are not part of the concept of an object ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jerico.dev</name></author>	</entry>

	<entry>
		<id>http://pkp-www.lib.sfu.ca:8084/wiki/index.php?title=Data_Access_Objects_(DAO)&amp;diff=1959&amp;oldid=prev</id>
		<title>Jerico.dev: Improved language</title>
		<link rel="alternate" type="text/html" href="http://pkp-www.lib.sfu.ca:8084/wiki/index.php?title=Data_Access_Objects_(DAO)&amp;diff=1959&amp;oldid=prev"/>
				<updated>2011-03-01T05:41:15Z</updated>
		
		<summary type="html">&lt;p&gt;Improved language&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr style='vertical-align: top;'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 05:41, 1 March 2011&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 110:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 110:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Please make sure, though, that the entities really implement a semantic concept that makes sense in &amp;quot;natural language&amp;quot;, i.e. a concept that is not only introduced for performance but immediately makes sense to those who read the code and those who use the application.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Please make sure, though, that the entities really implement a semantic concept that makes sense in &amp;quot;natural language&amp;quot;, i.e. a concept that is not only introduced for performance but immediately makes sense to those who read the code and those who use the application.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The current specializations of Submissions into &amp;quot;ReviewerSubmissions&amp;quot; or &amp;quot;AuthorSubmissions&amp;quot; with their corresponding DAOs are anti-patterns - you shouldn't reproduce those! They &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;create a very strong coupling between controllers and &lt;/del&gt;the DAO, break encapsulation, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;maintain &lt;/del&gt;duplicate code, do not improve performance and not even reduce complexity. They could be implemented more elegantly with the other design options outlined above.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The current specializations of Submissions into &amp;quot;ReviewerSubmissions&amp;quot; or &amp;quot;AuthorSubmissions&amp;quot; with their corresponding DAOs are anti-patterns - you shouldn't reproduce those! They &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;couple &lt;/ins&gt;the DAO &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;to specific controller transactions&lt;/ins&gt;, break encapsulation &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;and good separation of concerns&lt;/ins&gt;, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;produce &lt;/ins&gt;duplicate code, do not improve performance and not even reduce complexity. They could be implemented &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;much &lt;/ins&gt;more elegantly with the other design options outlined above.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;= Common DAO Design Errors =&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;= Common DAO Design Errors =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jerico.dev</name></author>	</entry>

	<entry>
		<id>http://pkp-www.lib.sfu.ca:8084/wiki/index.php?title=Data_Access_Objects_(DAO)&amp;diff=1958&amp;oldid=prev</id>
		<title>Jerico.dev: Describe the situation with multiple inheritance levels and hierarchies.</title>
		<link rel="alternate" type="text/html" href="http://pkp-www.lib.sfu.ca:8084/wiki/index.php?title=Data_Access_Objects_(DAO)&amp;diff=1958&amp;oldid=prev"/>
				<updated>2011-03-01T05:36:17Z</updated>
		
		<summary type="html">&lt;p&gt;Describe the situation with multiple inheritance levels and hierarchies.&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr style='vertical-align: top;'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 05:36, 1 March 2011&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 18:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 18:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;= Polymorphism =&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;= Polymorphism =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The relational data model does not implement polymorphism out-of-the-box. This means that as soon as DOs are polymorphic we'll no longer have a clean one-to-one relationship between database entities (aka &amp;quot;tables&amp;quot;) and domain objects. An object-relational (O/R) mapping will be required. The three standard O/R mappings for polymorphic objects are: Single Table Inheritance, Class Table Inheritance and Concrete Table Inheritance. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;No description &lt;/del&gt;here - &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;descriptions &lt;/del&gt;are &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;easily to be found &lt;/del&gt;on the web.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The relational data model does not implement polymorphism out-of-the-box. This means that as soon as DOs are polymorphic we'll no longer have a clean one-to-one relationship between database entities (aka &amp;quot;tables&amp;quot;) and domain objects. An object-relational (O/R) mapping will be required. The three standard O/R mappings for polymorphic objects are: Single Table Inheritance, Class Table Inheritance and Concrete Table Inheritance. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;I won't describe these standards &lt;/ins&gt;here - &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;they &lt;/ins&gt;are &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;well documented &lt;/ins&gt;on the web.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The standard pattern for an inheritance mapper is like this:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The standard pattern for an inheritance mapper is like this:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 24:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 24:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Image:Inheritance_Mapper.png]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Image:Inheritance_Mapper.png]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;In the given example, the SubmissionFileDAO will often be the only DAO required to handle access to mixed lists of files. Whenever the implementation doesn't matter you'll use the methods of the domain object DAO to access objects from the whole inheritance hierarchy. The DAO will make sure that monograph files will be instantiated as MonographFile and artwork files as ArtworkFile classes.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;In the given example, the SubmissionFileDAO will often be the only DAO required to handle access to mixed lists of files. Whenever the implementation doesn't matter you'll use the methods of the domain object DAO to access objects from the whole inheritance hierarchy. The DAO will make sure that monograph files will be instantiated as MonographFile and artwork files as ArtworkFile classes&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;. It will also transparently convert between implementations when necessary&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;To achieve this, the SubmissionFileDAO will delegate to one of the two concrete DAOs when one of its methods is being invoked. It identifies the right DAO either by inspecting the type of the object (on update/insert) or by querying the base table that contains some type indicator (on read access, e.g. genre in the case of the monograph/artwork file distinction).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;To achieve this, the SubmissionFileDAO will delegate to one of the two concrete DAOs when one of its methods is being invoked. It identifies the right DAO either by inspecting the type of the object (on update/insert) or by querying the base table that contains some type indicator (on read access, e.g. genre in the case of the monograph/artwork file distinction).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 33:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 33:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;You can use one of the concrete DAOs in your handler but only if you really want to deal with that specific domain object type. If you implement a special artwork file editing form for example it may make sense to use the ArtworkFileDAO directly. Most of the time access through the domain object DAO should be preferred, though, as it will deal with most cases and is easier to extend and maintain.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;You can use one of the concrete DAOs in your handler but only if you really want to deal with that specific domain object type. If you implement a special artwork file editing form for example it may make sense to use the ArtworkFileDAO directly. Most of the time access through the domain object DAO should be preferred, though, as it will deal with most cases and is easier to extend and maintain.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Please keep in mind that not all inheritance hierarchies are as simple as this one. There are usually multiple children to one parent class, otherwise inheritance wouldn't make sense after all. There is often not such a clear-cut design, then. You'll have to decide which parts of the inheritance hierarchy need their own &amp;quot;orchestrating&amp;quot; DAO managing concrete DAOs. You can also nest &amp;quot;orchestrating&amp;quot; DAOs into each other so that what is an &amp;quot;orchestrating&amp;quot; DAO on one level appears as a &amp;quot;concrete&amp;quot; DAO from the viewpoint of an &amp;quot;orchestrating&amp;quot; DAO on a higher level.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;= Mapping Relations Between Objects =&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;= Mapping Relations Between Objects =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jerico.dev</name></author>	</entry>

	<entry>
		<id>http://pkp-www.lib.sfu.ca:8084/wiki/index.php?title=Data_Access_Objects_(DAO)&amp;diff=1957&amp;oldid=prev</id>
		<title>Jerico.dev: Small improvements</title>
		<link rel="alternate" type="text/html" href="http://pkp-www.lib.sfu.ca:8084/wiki/index.php?title=Data_Access_Objects_(DAO)&amp;diff=1957&amp;oldid=prev"/>
				<updated>2011-03-01T05:30:01Z</updated>
		
		<summary type="html">&lt;p&gt;Small improvements&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr style='vertical-align: top;'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 05:30, 1 March 2011&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 2:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 2:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Typical properties of implementations of the Data Access Object (DAO) pattern in the context of a Model-View-Controller (MVC) application as ours are:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Typical properties of implementations of the Data Access Object (DAO) pattern in the context of a Model-View-Controller (MVC) application as ours are:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* The DAO maps the relational database model to an OO model thereby bridging the &amp;quot;impedance&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;quot; &lt;/del&gt;mismatch of these two data modeling approaches. It also sometimes hides implementation details of specific storage technologies (e.g. different database vendors). The latter is often, at least partially, delegated to a special data access abstraction layer, though (i.e. ADOdb in our case or maybe PDO in the future). &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;This decouples &lt;/del&gt;the controller from the relational data model and from database implementation details.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* The DAO maps the relational database model to an OO model thereby bridging the &amp;quot;impedance mismatch&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;quot; &lt;/ins&gt;of these two data modeling approaches. It also sometimes hides implementation details of specific storage technologies (e.g. different database vendors). The latter is often, at least partially, delegated to a special data access abstraction layer, though (i.e. ADOdb in our case or maybe PDO in the future). &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;DAOs are designed to decouple &lt;/ins&gt;the controller from the relational data model and from database implementation details.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* The DAO usually implements a basic &amp;quot;Create-Read-Update-Delete&amp;quot; (CRUD) pattern to handle single instances of entity objects.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* The DAO usually implements a basic &amp;quot;Create-Read-Update-Delete&amp;quot; (CRUD) pattern to handle single instances of entity objects.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Most of the time additional use-case specific methods are required that batch-retrieve objects to improve data access performance &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;or &lt;/del&gt;populate objects differently, e.g. with or without dependent objects loaded.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Most of the time additional use-case specific methods are required that batch-retrieve objects to improve data access performance&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/ins&gt;populate objects differently, e.g. with or without dependent objects loaded &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;and deal with polymorphism&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* The DAO &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will usually return &lt;/del&gt;domain objects (DO) that represent instances of data entities (e.g. articles, users, etc.).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* The DAO &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;returns &lt;/ins&gt;domain objects (DO) that represent instances of data entities (e.g. articles, users, etc.).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* DOs contain either only values or in more recent design paradigms (domain driven design, DDD) values &amp;amp; domain-specific behavior. In our case we mostly stick to the value-only approach but exceptions confirm the rule and there's &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;not &lt;/del&gt;problem with that.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* DOs contain either only values or in more recent design paradigms (domain driven design, DDD) values &amp;amp; domain-specific behavior. In our case we mostly stick to the value-only approach but exceptions confirm the rule and there's &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;no &lt;/ins&gt;problem with that&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;. We do not usually use the data transfer object (DTO) pattern in the sense of untyped objects created on the fly to represent use-case specific data. There may be exceptions to this rule but you should try to always return fully populated DOs for better re-use of DAO methods&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* DAOs usually instantiate DOs and not the other way round except when implementing lazy-load (see below). If you can choose then you should avoid dependencies from the DO to the DAO to improve encapsulation.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* DAOs usually instantiate DOs and not the other way round except when implementing lazy-load (see below). If you can choose then you should avoid dependencies from the DO to the DAO to improve encapsulation.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;= DAO design problems and trade-offs =&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;= DAO design problems and trade-offs =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jerico.dev</name></author>	</entry>

	<entry>
		<id>http://pkp-www.lib.sfu.ca:8084/wiki/index.php?title=Data_Access_Objects_(DAO)&amp;diff=1956&amp;oldid=prev</id>
		<title>Jerico.dev: Describe relation tables with their own properties.</title>
		<link rel="alternate" type="text/html" href="http://pkp-www.lib.sfu.ca:8084/wiki/index.php?title=Data_Access_Objects_(DAO)&amp;diff=1956&amp;oldid=prev"/>
				<updated>2011-03-01T05:24:42Z</updated>
		
		<summary type="html">&lt;p&gt;Describe relation tables with their own properties.&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr style='vertical-align: top;'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 05:24, 1 March 2011&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 42:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 42:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* To which class belong(s) the object(s) you return?&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* To which class belong(s) the object(s) you return?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Do you implement a one-to-many relation and the related objects are only being used in the parent object? Or do you implement a one-to-many relation with an object that is (also) being used independently of the parent object or do you implement a many-to-many relationship?&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Do you implement a one-to-many relation and the related objects are only being used in the parent object? Or do you implement a one-to-many relation with an object that is (also) being used independently of the parent object or do you implement a many-to-many relationship?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;* Does the relation table contain only foreign keys or also additional attributes?&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* How expensive are simpler design options in terms of execution performance? What is the cost of additional complexity of different design options and what is the maintenance cost?&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* How expensive are simpler design options in terms of execution performance? What is the cost of additional complexity of different design options and what is the maintenance cost?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 66:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 67:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;# If this implementation is too expensive then you can load all related objects at once by implementing a corresponding method in the DAO of the related object. This implementation still keeps all SQL and object instantiation code for the related object in it's own DAO thereby improving encapsulation and code re-use. The disadvantage is that you'll have to implement specialized accessors that cannot be re-used as frequently as the basic accessors of the DAO.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;# If this implementation is too expensive then you can load all related objects at once by implementing a corresponding method in the DAO of the related object. This implementation still keeps all SQL and object instantiation code for the related object in it's own DAO thereby improving encapsulation and code re-use. The disadvantage is that you'll have to implement specialized accessors that cannot be re-used as frequently as the basic accessors of the DAO.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;# If this implementation is still too expensive then you can create a single SQL query that draws all required data together in the parent object's DAO and only delegate to the related object's DAO for object instantiation (calling its fromRow() method). This is the most performant method as it minimized the required roundtrips to the database. But this method requires much more complex code, breaks encapsulation and reduces re-use. It therefore only makes sense when you really have a noticeable performance problem to solve.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;# If this implementation is still too expensive then you can create a single SQL query that draws all required data together in the parent object's DAO and only delegate to the related object's DAO for object instantiation (calling its fromRow() method). This is the most performant method as it minimized the required roundtrips to the database. But this method requires much more complex code, breaks encapsulation and reduces re-use. It therefore only makes sense when you really have a noticeable performance problem to solve.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;=== Relations as independent domain objects ===&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;All the above cases assume that your relation table does not contain any additional attributes but only the foreign keys of the entities it relates to each other. It's a frequent error that pure relationship tables are accessed through their own DAO rather than through one of the above mapping patterns.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;It does happen, though, that relation tables themselves have properties. A good example are review assignments. While they relate submissions, review rounds and users (reviewers), they also contain a lot of additional properties like several review-related dates, status information, etc. In this case the relation table itself represents a domain object which is represented by it's own class or class hierarchy and will warrant an independent DAO. The only difference to &amp;quot;basic&amp;quot; entities is then that this domain object has a combined key.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== When to load dependent objects? ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== When to load dependent objects? ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jerico.dev</name></author>	</entry>

	</feed>