<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: Why On Earth Would A Developer Do This?</title> <atom:link href="http://davybrion.com/blog/2008/11/why-on-earth-would-a-developer-do-this/feed/" rel="self" type="application/rss+xml" /><link>http://davybrion.com/blog/2008/11/why-on-earth-would-a-developer-do-this/</link> <description>inquisitive: adjective. given to inquiry, research, or asking questions; eager for knowledge; intellectually curious</description> <lastBuildDate>Sun, 20 May 2012 21:55:00 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>By: Uncle Bob Martin</title><link>http://davybrion.com/blog/2008/11/why-on-earth-would-a-developer-do-this/comment-page-1/#comment-106291</link> <dc:creator>Uncle Bob Martin</dc:creator> <pubDate>Wed, 16 May 2012 15:43:00 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=607#comment-106291</guid> <description>Davy:  Certainly there should be an API for caching.  However, I don&#039;t want the business rules knowing about that.  The business rules should be independent of those kinds of concerns.  If the business rules are coupled to all the physical constraints of the system, then they will be very complex, and fragile.  Whenever one of those constraints changes, the business rules will have to be changed too.  </description> <content:encoded><![CDATA[<p>Davy:  Certainly there should be an API for caching.  However, I don&#8217;t want the business rules knowing about that.  The business rules should be independent of those kinds of concerns.  If the business rules are coupled to all the physical constraints of the system, then they will be very complex, and fragile.  Whenever one of those constraints changes, the business rules will have to be changed too.  </p> ]]></content:encoded> </item> <item><title>By: Davy Brion</title><link>http://davybrion.com/blog/2008/11/why-on-earth-would-a-developer-do-this/comment-page-1/#comment-106290</link> <dc:creator>Davy Brion</dc:creator> <pubDate>Wed, 16 May 2012 14:44:00 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=607#comment-106290</guid> <description>regardless of the data store being used, wouldn&#039;t it make much more sense to make things like potential caching of data and/or paging through the results explicit in the API? Wouldn&#039;t that make the code less ambiguous? Isn&#039;t that an important part of writing clean code?</description> <content:encoded><![CDATA[<p>regardless of the data store being used, wouldn&#8217;t it make much more sense to make things like potential caching of data and/or paging through the results explicit in the API? Wouldn&#8217;t that make the code less ambiguous? Isn&#8217;t that an important part of writing clean code?</p> ]]></content:encoded> </item> <item><title>By: Uncle Bob Martin</title><link>http://davybrion.com/blog/2008/11/why-on-earth-would-a-developer-do-this/comment-page-1/#comment-106289</link> <dc:creator>Uncle Bob Martin</dc:creator> <pubDate>Wed, 16 May 2012 14:37:00 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=607#comment-106289</guid> <description>Davy,  notice how your discussion implies something.  It implies that the design of a system should be wrapped around the database.  You are worried about &#039;select&#039; statement in the middle of a business rule!  In other words, you believe that this business rule is _coupled_ to the database in an intimate way.  You know that hammering a database with individual select statements is slow, and so you conclude that the above is terrible code.I can see why you might have thought this to be true, since the code _does_ have a PayrollDatabase object; and one simplistic implementation of that object might be to bind it directly to a SQL database.  Indeed, early in the development of the application, such an implementation would likely be the norm.  On the other hand, what if I were using an in-memory database? What if, prior to executing this code, I simply cached all the employees in memory?  What if I were using CouchDB, or Mongo, or BigTable?  Or what if the PayrollDatabase object was clever enough to fetch and cache 50, or 100, or 1000 employees every time it got a cache miss?  Would you have the same complaint?The point is that there are many interesting ways to avoid coupling your business rule code to the hard details of a relational database.  And there are many reasons why this is a good idea.Databases are details; they are not the core of your system.  A good system architect pushes the database out to the edges of the system and breaks all couplings of the use cases and business rules upon it.  This allows the system to use any kind of data storage mechanism it might need, now, or in the future.  Davy, you are absolutely right.  If I knew that I was using a SQL database, and would always be using a SQL database, then I would change that algorithm to take advantage of that knowledge.  But I don&#039;t know that I&#039;m using a SQL database.  I don&#039;t know it because I don&#039;t _want_ to know it.  I want that information hidden, because I don&#039;t want to depend upon it.  That means that I am free to write the business rule code in the manner that seems most expressive and clear to me; and to move the problem to the code that connects the business rules to the database.
For more on this, see the cleancoders.com videos on Architecture, Form, Functions, The Single Responsibility Principle, and The Open Closed Principle.  </description> <content:encoded><![CDATA[<p>Davy,  notice how your discussion implies something.  It implies that the design of a system should be wrapped around the database.  You are worried about &#8216;select&#8217; statement in the middle of a business rule!  In other words, you believe that this business rule is _coupled_ to the database in an intimate way.  You know that hammering a database with individual select statements is slow, and so you conclude that the above is terrible code.</p><p>I can see why you might have thought this to be true, since the code _does_ have a PayrollDatabase object; and one simplistic implementation of that object might be to bind it directly to a SQL database.  Indeed, early in the development of the application, such an implementation would likely be the norm.  On the other hand, what if I were using an in-memory database? What if, prior to executing this code, I simply cached all the employees in memory?  What if I were using CouchDB, or Mongo, or BigTable?  Or what if the PayrollDatabase object was clever enough to fetch and cache 50, or 100, or 1000 employees every time it got a cache miss?  Would you have the same complaint?</p><p>The point is that there are many interesting ways to avoid coupling your business rule code to the hard details of a relational database.  And there are many reasons why this is a good idea.</p><p>Databases are details; they are not the core of your system.  A good system architect pushes the database out to the edges of the system and breaks all couplings of the use cases and business rules upon it.  This allows the system to use any kind of data storage mechanism it might need, now, or in the future.  </p><p>Davy, you are absolutely right.  If I knew that I was using a SQL database, and would always be using a SQL database, then I would change that algorithm to take advantage of that knowledge.  But I don&#8217;t know that I&#8217;m using a SQL database.  I don&#8217;t know it because I don&#8217;t _want_ to know it.  I want that information hidden, because I don&#8217;t want to depend upon it.  That means that I am free to write the business rule code in the manner that seems most expressive and clear to me; and to move the problem to the code that connects the business rules to the database.<br
/> For more on this, see the cleancoders.com videos on Architecture, Form, Functions, The Single Responsibility Principle, and The Open Closed Principle.  </p> ]]></content:encoded> </item> <item><title>By: Clean Code Versus Great Code</title><link>http://davybrion.com/blog/2008/11/why-on-earth-would-a-developer-do-this/comment-page-1/#comment-100336</link> <dc:creator>Clean Code Versus Great Code</dc:creator> <pubDate>Thu, 21 Jul 2011 16:01:48 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=607#comment-100336</guid> <description>[...] A lot of people love to talk the talk when it comes to writing clean code. They&#039;ll stress their dedication to it, in some cases even wearing Uncle Bob&#039;s green band while coding so they&#039;ll never lose sight of what&#039;s incredibly important to them: writing clean code. Unfortunately, i&#039;ve noticed on numerous occasions that many of these people don&#039;t always put as much emphasis on what the code is doing compared to how it looks. Sometimes they don&#039;t really bother to learn what their ORM is doing behind the scenes. Or they&#039;ll prefer to use something like Automapper to map entities to DTO&#039;s even though it is woefully inefficient compared to simply retrieving projected data. They don&#039;t always think about the cost of multiple remote calls or sending way too much data over the wire. And when they&#039;re not perfecting the art of writing bowling games over and over again, they just might hit the database in loop. [...]</description> <content:encoded><![CDATA[<p>[...] A lot of people love to talk the talk when it comes to writing clean code. They&#039;ll stress their dedication to it, in some cases even wearing Uncle Bob&#039;s green band while coding so they&#039;ll never lose sight of what&#039;s incredibly important to them: writing clean code. Unfortunately, i&#039;ve noticed on numerous occasions that many of these people don&#039;t always put as much emphasis on what the code is doing compared to how it looks. Sometimes they don&#039;t really bother to learn what their ORM is doing behind the scenes. Or they&#039;ll prefer to use something like Automapper to map entities to DTO&#039;s even though it is woefully inefficient compared to simply retrieving projected data. They don&#039;t always think about the cost of multiple remote calls or sending way too much data over the wire. And when they&#039;re not perfecting the art of writing bowling games over and over again, they just might hit the database in loop. [...]</p> ]]></content:encoded> </item> <item><title>By: Mai Kalange</title><link>http://davybrion.com/blog/2008/11/why-on-earth-would-a-developer-do-this/comment-page-1/#comment-6327</link> <dc:creator>Mai Kalange</dc:creator> <pubDate>Fri, 12 Dec 2008 18:30:22 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=607#comment-6327</guid> <description>I guess it adds weight to the maxim...&quot;Refactor mercilessly&quot;</description> <content:encoded><![CDATA[<p>I guess it adds weight to the maxim&#8230;&#8221;Refactor mercilessly&#8221;</p> ]]></content:encoded> </item> <item><title>By: Davy Brion</title><link>http://davybrion.com/blog/2008/11/why-on-earth-would-a-developer-do-this/comment-page-1/#comment-6159</link> <dc:creator>Davy Brion</dc:creator> <pubDate>Tue, 09 Dec 2008 09:30:40 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=607#comment-6159</guid> <description>hmm... apples and orangescriticizing code in a blog post and working with teammates are two entirely different things. for starters, when one of my teammates writes code that needs improvements, i explain them what&#039;s wrong with it and how we can improve it. There&#039;s no criticizing going on there.</description> <content:encoded><![CDATA[<p>hmm&#8230; apples and oranges</p><p>criticizing code in a blog post and working with teammates are two entirely different things. for starters, when one of my teammates writes code that needs improvements, i explain them what&#8217;s wrong with it and how we can improve it. There&#8217;s no criticizing going on there.</p> ]]></content:encoded> </item> <item><title>By: Peter</title><link>http://davybrion.com/blog/2008/11/why-on-earth-would-a-developer-do-this/comment-page-1/#comment-6155</link> <dc:creator>Peter</dc:creator> <pubDate>Tue, 09 Dec 2008 08:49:49 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=607#comment-6155</guid> <description>Having read your post on a great technical lead, I doubt I would ever wish to work under you, with your criticising and your to-the-heart laments.    I respect you say in your technical lead blog you do try to aspire to those values you present.  I think you just have a long way to go.Peter.</description> <content:encoded><![CDATA[<p>Having read your post on a great technical lead, I doubt I would ever wish to work under you, with your criticising and your to-the-heart laments.    I respect you say in your technical lead blog you do try to aspire to those values you present.  I think you just have a long way to go.</p><p>Peter.</p> ]]></content:encoded> </item> <item><title>By: Jonathan Rockway</title><link>http://davybrion.com/blog/2008/11/why-on-earth-would-a-developer-do-this/comment-page-1/#comment-6066</link> <dc:creator>Jonathan Rockway</dc:creator> <pubDate>Sun, 07 Dec 2008 06:33:48 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=607#comment-6066</guid> <description>Where exactly does the code say that it is connecting to a relational database?  How do we know that the PayrollDatabase is not an in-memory structure?  If it is connecting to a relational database, how do we know that the query is not done at the &quot;PayrollDatabase.GetAllEmployeeIds()&quot; call and then the results cached for the scope of the executing block?Basically, you are assuming a particular implementation of the PayrollDatabase, and are criticizing that implementation.  I have worked on many projects where the ORM is smart enough to optimize cases like this, or where the data is already in memory, and I only &quot;pay&quot; for the method call.  (The only thing I would change is to remove the part where we get the IDs, and instead get an iterator over the objects.  If you want to criticize an API that exposes arbitrary IDs, I am fine with that.)</description> <content:encoded><![CDATA[<p>Where exactly does the code say that it is connecting to a relational database?  How do we know that the PayrollDatabase is not an in-memory structure?  If it is connecting to a relational database, how do we know that the query is not done at the &#8220;PayrollDatabase.GetAllEmployeeIds()&#8221; call and then the results cached for the scope of the executing block?</p><p>Basically, you are assuming a particular implementation of the PayrollDatabase, and are criticizing that implementation.  I have worked on many projects where the ORM is smart enough to optimize cases like this, or where the data is already in memory, and I only &#8220;pay&#8221; for the method call.  (The only thing I would change is to remove the part where we get the IDs, and instead get an iterator over the objects.  If you want to criticize an API that exposes arbitrary IDs, I am fine with that.)</p> ]]></content:encoded> </item> <item><title>By: Cristian</title><link>http://davybrion.com/blog/2008/11/why-on-earth-would-a-developer-do-this/comment-page-1/#comment-6041</link> <dc:creator>Cristian</dc:creator> <pubDate>Sat, 06 Dec 2008 15:15:31 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=607#comment-6041</guid> <description>That code is stupid, with or without a database. What&#039;s the point in getting all the IDs and then the object for each ID, when you could iterate over the whole collection using a &lt;em&gt;foreach&lt;/em&gt; statement? This is what I would call a proper abstraction.</description> <content:encoded><![CDATA[<p>That code is stupid, with or without a database. What&#8217;s the point in getting all the IDs and then the object for each ID, when you could iterate over the whole collection using a <em>foreach</em> statement? This is what I would call a proper abstraction.</p> ]]></content:encoded> </item> <item><title>By: daniel fernandes</title><link>http://davybrion.com/blog/2008/11/why-on-earth-would-a-developer-do-this/comment-page-1/#comment-5988</link> <dc:creator>daniel fernandes</dc:creator> <pubDate>Fri, 05 Dec 2008 08:12:58 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=607#comment-5988</guid> <description>Frederik Gheysels:
I don&#039;t see why you can&#039;t create a specialized entity, call it a DTO, that shares some of the implementation of Employee but this time mapped as Davy said to a View.
Using full blown Entities for batch processing is fine for small jobs but that just doesn&#039;t scale. Using a &quot;DTO&quot; would allow to use the same infrastructure as with the Entities but would provide tremendous performance benefits.
Daniel</description> <content:encoded><![CDATA[<p>Frederik Gheysels:<br
/> I don&#8217;t see why you can&#8217;t create a specialized entity, call it a DTO, that shares some of the implementation of Employee but this time mapped as Davy said to a View.<br
/> Using full blown Entities for batch processing is fine for small jobs but that just doesn&#8217;t scale. Using a &#8220;DTO&#8221; would allow to use the same infrastructure as with the Entities but would provide tremendous performance benefits.<br
/> Daniel</p> ]]></content:encoded> </item> <item><title>By: Davy Brion</title><link>http://davybrion.com/blog/2008/11/why-on-earth-would-a-developer-do-this/comment-page-1/#comment-5697</link> <dc:creator>Davy Brion</dc:creator> <pubDate>Wed, 26 Nov 2008 19:17:15 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=607#comment-5697</guid> <description>in that case i&#039;d probably try to get it working without the paging at first. then i&#039;d test it it with a very large set of data to make sure i really do need to use paging.  How many products are we talking about?If paging really is necessary, a good solution to this problem is something that&#039;s probably gonna require a bit of experimentation... i can&#039;t just think of something that would definitely be great for this situation... sorry :)</description> <content:encoded><![CDATA[<p>in that case i&#8217;d probably try to get it working without the paging at first. then i&#8217;d test it it with a very large set of data to make sure i really do need to use paging.  How many products are we talking about?</p><p>If paging really is necessary, a good solution to this problem is something that&#8217;s probably gonna require a bit of experimentation&#8230; i can&#8217;t just think of something that would definitely be great for this situation&#8230; sorry <img
src='http://d18sni7re4ly7f.cloudfront.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> ]]></content:encoded> </item> <item><title>By: Frederik Gheysels</title><link>http://davybrion.com/blog/2008/11/why-on-earth-would-a-developer-do-this/comment-page-1/#comment-5692</link> <dc:creator>Frederik Gheysels</dc:creator> <pubDate>Wed, 26 Nov 2008 16:25:53 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=607#comment-5692</guid> <description>Well, that&#039;s just what I was trying to say: you cannot use a DTO, since determining the price that has to be exported, is a quite complex task which cannot be handled by SQL.
So, you&#039;ll need to retrieve all the prices of a product, so that you can use the &#039;DeterminePrice( params )&#039; member method of the Product class ...
That&#039;s the reason why you cannot use a DTO.Therefore, what solution would you use in this particular case ?I&#039;m trying to create a &#039;PagedResults&#039; class, which is given an ICriteria.
The PagedResults class would then use the SetFirstResults &amp; SetMaxResults methods to retrieve the required entities in &#039;chunks&#039;.  But, then I am faced with the problems I&#039;ve described in my earlier comment.
So, I&#039;ve decided to modify my &#039;PagedResults&#039; class a bit, so that I first retrieve the next &#039;n&#039; Id&#039;s, and then I let NHIbernate retrieve the entities for those Id&#039;s (in one go), but this is a bit problematic as well ...</description> <content:encoded><![CDATA[<p>Well, that&#8217;s just what I was trying to say: you cannot use a DTO, since determining the price that has to be exported, is a quite complex task which cannot be handled by SQL.<br
/> So, you&#8217;ll need to retrieve all the prices of a product, so that you can use the &#8216;DeterminePrice( params )&#8217; member method of the Product class &#8230;<br
/> That&#8217;s the reason why you cannot use a DTO.</p><p>Therefore, what solution would you use in this particular case ?</p><p>I&#8217;m trying to create a &#8216;PagedResults&#8217; class, which is given an ICriteria.<br
/> The PagedResults class would then use the SetFirstResults &amp; SetMaxResults methods to retrieve the required entities in &#8216;chunks&#8217;.  But, then I am faced with the problems I&#8217;ve described in my earlier comment.<br
/> So, I&#8217;ve decided to modify my &#8216;PagedResults&#8217; class a bit, so that I first retrieve the next &#8216;n&#8217; Id&#8217;s, and then I let NHIbernate retrieve the entities for those Id&#8217;s (in one go), but this is a bit problematic as well &#8230;</p> ]]></content:encoded> </item> <item><title>By: Davy Brion</title><link>http://davybrion.com/blog/2008/11/why-on-earth-would-a-developer-do-this/comment-page-1/#comment-5685</link> <dc:creator>Davy Brion</dc:creator> <pubDate>Wed, 26 Nov 2008 15:34:59 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=607#comment-5685</guid> <description>why wouldn&#039;t i use a DTO for this? it appears to be the most optimal solution... you could map the DTO to a view which retrieves the correct data and that would be all there is to it.  If you want to use paging on that view, there&#039;s no problem either...</description> <content:encoded><![CDATA[<p>why wouldn&#8217;t i use a DTO for this? it appears to be the most optimal solution&#8230; you could map the DTO to a view which retrieves the correct data and that would be all there is to it.  If you want to use paging on that view, there&#8217;s no problem either&#8230;</p> ]]></content:encoded> </item> <item><title>By: Frederik Gheysels</title><link>http://davybrion.com/blog/2008/11/why-on-earth-would-a-developer-do-this/comment-page-1/#comment-5684</link> <dc:creator>Frederik Gheysels</dc:creator> <pubDate>Wed, 26 Nov 2008 15:11:41 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=607#comment-5684</guid> <description>Hmm, how would you handle this situation:Suppose you&#039;ve an entity that is mapped against multiple tables. In other words, the entity has a number of collections which contain related information.
For instance, you have a class &#039;Product&#039;, which has a collection of &#039;Prices&#039;, and a collection of &#039;Names&#039; (for every language, a different name), etc...You need to write the Product information to a file, and this file contains, for each product, the price that is currently valid, and the ProductName for a specific language.
(You cannot use a DTO to retrieve the Products :) ).If you use the &#039;paging&#039; capabilities of NHibernate, NHibernate will issue several SELECT statements, which retrieve a recordset of n rows (where n is the &#039;page-size&#039; that you&#039;ve specified).
However, this recordset of n rows maybe contains information for n / 2 entities:
Since the entity has a collection of Names and Prices, the recordset contains a row for every Product/ProductName/ProductPrice.
This means that, if a product has 2 names and 3 prices, the recordset will contain 2*3 records for one Product.
Then, the pages will contain fewer entities then you&#039;ve specified.How would you solve this ?
One could argue that the Names and Prices should be loaded lazily, but, when you do that, you&#039;ll find yourself in the same situation as the piece of code you&#039;ve posted:
multiple queries will be fired in the loop where you iterate over every Product that you&#039;ve loaded ...</description> <content:encoded><![CDATA[<p>Hmm, how would you handle this situation:</p><p>Suppose you&#8217;ve an entity that is mapped against multiple tables. In other words, the entity has a number of collections which contain related information.<br
/> For instance, you have a class &#8216;Product&#8217;, which has a collection of &#8216;Prices&#8217;, and a collection of &#8216;Names&#8217; (for every language, a different name), etc&#8230;</p><p>You need to write the Product information to a file, and this file contains, for each product, the price that is currently valid, and the ProductName for a specific language.<br
/> (You cannot use a DTO to retrieve the Products <img
src='http://d18sni7re4ly7f.cloudfront.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ).</p><p>If you use the &#8216;paging&#8217; capabilities of NHibernate, NHibernate will issue several SELECT statements, which retrieve a recordset of n rows (where n is the &#8216;page-size&#8217; that you&#8217;ve specified).<br
/> However, this recordset of n rows maybe contains information for n / 2 entities:<br
/> Since the entity has a collection of Names and Prices, the recordset contains a row for every Product/ProductName/ProductPrice.<br
/> This means that, if a product has 2 names and 3 prices, the recordset will contain 2*3 records for one Product.<br
/> Then, the pages will contain fewer entities then you&#8217;ve specified.</p><p>How would you solve this ?<br
/> One could argue that the Names and Prices should be loaded lazily, but, when you do that, you&#8217;ll find yourself in the same situation as the piece of code you&#8217;ve posted:<br
/> multiple queries will be fired in the loop where you iterate over every Product that you&#8217;ve loaded &#8230;</p> ]]></content:encoded> </item> <item><title>By: Davy Brion</title><link>http://davybrion.com/blog/2008/11/why-on-earth-would-a-developer-do-this/comment-page-1/#comment-5680</link> <dc:creator>Davy Brion</dc:creator> <pubDate>Wed, 26 Nov 2008 12:30:30 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=607#comment-5680</guid> <description>This really isn&#039;t just a case of premature optimization... but going to the database in a loop is about the dumbest thing you can do.and again, as far as the readability is concerned, i&#039;ll just copy/paste something from one of the earlier comments:&quot;how is the above code cleaner, simpler and more readable than simply looping through the return value of PayrollDatabase.GetAllEmployees?&quot;</description> <content:encoded><![CDATA[<p>This really isn&#8217;t just a case of premature optimization&#8230; but going to the database in a loop is about the dumbest thing you can do.</p><p>and again, as far as the readability is concerned, i&#8217;ll just copy/paste something from one of the earlier comments:</p><p>&#8220;how is the above code cleaner, simpler and more readable than simply looping through the return value of PayrollDatabase.GetAllEmployees?&#8221;</p> ]]></content:encoded> </item> <item><title>By: Angel</title><link>http://davybrion.com/blog/2008/11/why-on-earth-would-a-developer-do-this/comment-page-1/#comment-5679</link> <dc:creator>Angel</dc:creator> <pubDate>Wed, 26 Nov 2008 12:26:13 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=607#comment-5679</guid> <description>Optimize later:Using an ORM-like approach is a good thing, code is read much more times that it get&#039;s writed, and if the performance of the program is Ok I don&#039;t see a reason why &quot;optimize&quot; it. The question here is: Is it worth to optimize the code to make just one SQL query instead of six?Premature optimization is the most common cause of project failures.</description> <content:encoded><![CDATA[<p>Optimize later:</p><p>Using an ORM-like approach is a good thing, code is read much more times that it get&#8217;s writed, and if the performance of the program is Ok I don&#8217;t see a reason why &#8220;optimize&#8221; it. The question here is: Is it worth to optimize the code to make just one SQL query instead of six?</p><p>Premature optimization is the most common cause of project failures.</p> ]]></content:encoded> </item> <item><title>By: Davy Brion</title><link>http://davybrion.com/blog/2008/11/why-on-earth-would-a-developer-do-this/comment-page-1/#comment-5644</link> <dc:creator>Davy Brion</dc:creator> <pubDate>Tue, 25 Nov 2008 17:01:37 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=607#comment-5644</guid> <description>like i said earlier, if it was a simple comparison then i&#039;d put it in the where clause as well... if the check is more complex, then i&#039;d rather keep that logic outside of the queries as well</description> <content:encoded><![CDATA[<p>like i said earlier, if it was a simple comparison then i&#8217;d put it in the where clause as well&#8230; if the check is more complex, then i&#8217;d rather keep that logic outside of the queries as well</p> ]]></content:encoded> </item> <item><title>By: Mwanji Ezana</title><link>http://davybrion.com/blog/2008/11/why-on-earth-would-a-developer-do-this/comment-page-1/#comment-5643</link> <dc:creator>Mwanji Ezana</dc:creator> <pubDate>Tue, 25 Nov 2008 16:29:10 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=607#comment-5643</guid> <description>&quot;btw, how is the above code cleaner, simpler and more readable than simply looping through the return value of PayrollDatabase.GetAllEmployees?&quot;If we&#039;re only interested in the employees whose pay date is today, why pull all the employees out of the DB? A simple where clause would return only the employees of interest, shifting computation to the most optimised place (the DB server) and generating a much smaller set to loop over.</description> <content:encoded><![CDATA[<p>&#8220;btw, how is the above code cleaner, simpler and more readable than simply looping through the return value of PayrollDatabase.GetAllEmployees?&#8221;</p><p>If we&#8217;re only interested in the employees whose pay date is today, why pull all the employees out of the DB? A simple where clause would return only the employees of interest, shifting computation to the most optimised place (the DB server) and generating a much smaller set to loop over.</p> ]]></content:encoded> </item> <item><title>By: Ray Bird</title><link>http://davybrion.com/blog/2008/11/why-on-earth-would-a-developer-do-this/comment-page-1/#comment-5641</link> <dc:creator>Ray Bird</dc:creator> <pubDate>Tue, 25 Nov 2008 16:25:35 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=607#comment-5641</guid> <description>Yup, see ya in the soup line!</description> <content:encoded><![CDATA[<p>Yup, see ya in the soup line!</p> ]]></content:encoded> </item> <item><title>By: Davy Brion</title><link>http://davybrion.com/blog/2008/11/why-on-earth-would-a-developer-do-this/comment-page-1/#comment-5640</link> <dc:creator>Davy Brion</dc:creator> <pubDate>Tue, 25 Nov 2008 16:13:59 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=607#comment-5640</guid> <description>so those petty insults kinda look stupid now huh? :p</description> <content:encoded><![CDATA[<p>so those petty insults kinda look stupid now huh? :p</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 4/26 queries in 0.018 seconds using disk: basic
Object Caching 649/654 objects using disk: basic
Content Delivery Network via Amazon Web Services: CloudFront: d18sni7re4ly7f.cloudfront.net

Served from: davybrion.com @ 2012-05-21 13:52:51 -->
