﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Daniel K commented on Answer: This code should never hit production</title><description>From a Windows application development background  i'd say "what's paging?" ;-)
</description><link>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment16</link><guid>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment16</guid><pubDate>Mon, 03 Jan 2011 19:16:06 GMT</pubDate></item><item><title>Ayende Rahien commented on Answer: This code should never hit production</title><description>Naiem,
  
Because there is no other query running, this is a separate step that is never joined with anything else.
  
</description><link>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment15</link><guid>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment15</guid><pubDate>Sun, 26 Dec 2010 06:34:41 GMT</pubDate></item><item><title>Naiem commented on Answer: This code should never hit production</title><description>Doing query optimization is very hard with this approach. Why not yield return everywhere, and do the paging in a separate level. It generates annoying limitations, but it is the only way to let query optimizer do its job properly.
</description><link>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment14</link><guid>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment14</guid><pubDate>Sun, 26 Dec 2010 05:56:01 GMT</pubDate></item><item><title>jdn commented on Answer: This code should never hit production</title><description>Yes, when faced with bad designs poorly thought out, you pull a Rocky Lhotka and treat the symptom.  Software design for children.
  
  
I can just imagine telling the boss "No sir, we aren't going to let you pull back all of the open orders in your trading system because it's possible that somewhere down the road BAD THINGS HAPPEN.  No, we aren't going to do an analysis of what our systems will need to handle and design and architect it accordingly, we're just going to silently cripple it."
  
  
The least you can do, if you are crippling "select *" because the people who use your software aren't professional or even basically competent, is log the fact when you break.
  
  
Running with scissors?  Ha.
</description><link>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment13</link><guid>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment13</guid><pubDate>Sat, 25 Dec 2010 16:18:57 GMT</pubDate></item><item><title>Ayende Rahien commented on Answer: This code should never hit production</title><description>Oleksii,
  
SRP isn't part of this.
  
You enforce paging for the same reason that you validate input, because if you don't, Bad Things happen.
  
And the information is already sorted.
  
</description><link>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment12</link><guid>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment12</guid><pubDate>Sat, 25 Dec 2010 14:36:09 GMT</pubDate></item><item><title>Ayende Rahien commented on Answer: This code should never hit production</title><description>Frank,
  
Because what we are disposing and the value we return are two different thing.
  
The using statement denotes context (more specifically, it denotes a reference counting scheme), the out variable denotes the value to actually use.
  
  
As for Term().Text(), that is part of the Lucene library that I am using
</description><link>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment11</link><guid>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment11</guid><pubDate>Sat, 25 Dec 2010 14:32:21 GMT</pubDate></item><item><title>Ayende Rahien commented on Answer: This code should never hit production</title><description>Jdn,
  
I have seen too many systems where unbounded result sets brought the system to its knees.
  
Not on my watch
</description><link>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment10</link><guid>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment10</guid><pubDate>Sat, 25 Dec 2010 14:31:18 GMT</pubDate></item><item><title>Ayende Rahien commented on Answer: This code should never hit production</title><description>Patrick,
  
That is why I have this line:
  
            while(fromValue.Equals(termEnum.Term().Text()))
  
It ensures that we skip to the next value.
</description><link>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment9</link><guid>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment9</guid><pubDate>Sat, 25 Dec 2010 14:30:43 GMT</pubDate></item><item><title>Oleksii commented on Answer: This code should never hit production</title><description>It seems to me a bit confusing to me. If you are using Single Responsibility principle, than this part of code should not have paging. Suppose, you are querying a database with:
  
SELECT * FROM tableName;
  
The server would return you all the records available, and will not limit the result, unless you specify it explicitly.
  
Following this idea, you can easily say that the code in the post lacks sorting and shall never hit production because of that. Paging is additional functionality, which should have been stated in the task, e.g. "this code lacks important additional functionality, what is it"?
  
  
Would you argue on my comment? Thanks!
  
  
Oleksii
</description><link>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment8</link><guid>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment8</guid><pubDate>Sat, 25 Dec 2010 13:50:45 GMT</pubDate></item><item><title>Frank Quednau commented on Answer: This code should never hit production</title><description>So, what's this affection with "out"? Why isn't the return value of "currentIndexSearcher.Use" the IndexSearcher you are initializing? Any particular reason?
  
  
And what with the Term().Text() stuff? Are they extension methods or have you abolished properties by some reason?
  
  
Is this actually production code now or is it just tuned to fit on one blog post? 
</description><link>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment7</link><guid>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment7</guid><pubDate>Fri, 24 Dec 2010 22:43:54 GMT</pubDate></item><item><title>jdn commented on Answer: This code should never hit production</title><description>Yeah, that 'bonus' code is an abomination, the same poor design flaw that hampered RavenDB until my patch fixed it ;)
  
  
And you are wrong in general, Paging is optional.  
</description><link>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment6</link><guid>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment6</guid><pubDate>Fri, 24 Dec 2010 17:11:17 GMT</pubDate></item><item><title>Patrick Huizinga commented on Answer: This code should never hit production</title><description>Ayende, what happens with repeating terms and 
__pageSize = 1
?
  
  
Hmm, thinking about it, I assume the index reader will start at the first item after the given term?
  
  
At first I was thinking about 
__termEnum
 as a regular enumeration from wich you could start halfway (like Enumerate.Skip). And with the index [ 1, 2, 2, 3 ] GetOldTerms() would result in the set [ 1, 2, 3 ] and GetTems(size = 2) and GetTerms(from 2, size = 2) would result in the sets [ 1, 2 ] and [ 2, 3 ].
  
  
I think I was wrong.
</description><link>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment5</link><guid>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment5</guid><pubDate>Fri, 24 Dec 2010 15:02:46 GMT</pubDate></item><item><title>Ayende Rahien commented on Answer: This code should never hit production</title><description>Patrick,
  
Terms can be repeated. But I don't see the difference that you mention, where is it?
  
  
Tommy,
  
You can, that is why you have the fromValue paramter for
</description><link>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment4</link><guid>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment4</guid><pubDate>Fri, 24 Dec 2010 12:02:05 GMT</pubDate></item><item><title>Tommy Carlier commented on Answer: This code should never hit production</title><description>Doesn't paging infer that you can access more than 1 page?
</description><link>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment3</link><guid>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment3</guid><pubDate>Fri, 24 Dec 2010 11:36:02 GMT</pubDate></item><item><title>Patrick Huizinga commented on Answer: This code should never hit production</title><description>Ayende, is it guaranteed each term only appears once in an index? Even in the case of a secondary index?
  
  
Because if a term could be repeated, the new method will actually produce different results compared to the old one.
</description><link>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment2</link><guid>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment2</guid><pubDate>Fri, 24 Dec 2010 11:00:05 GMT</pubDate></item><item><title>NC commented on Answer: This code should never hit production</title><description>Code still unreadable.
</description><link>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment1</link><guid>http://ayende.com/4733/answer-this-code-should-never-hit-production#comment1</guid><pubDate>Fri, 24 Dec 2010 10:46:46 GMT</pubDate></item></channel></rss>