﻿<?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>oskar commented on Unprofessional code, take II</title><description>Sorry,
Just got confused by the comment for the "if".</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment38</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment38</guid><pubDate>Wed, 18 Jul 2012 07:25:55 GMT</pubDate></item><item><title>Ayende Rahien commented on Unprofessional code, take II</title><description>Oskar,
If it has a where clause, we can't use it as an index for dynamic queries.
The code is good there.</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment37</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment37</guid><pubDate>Wed, 18 Jul 2012 07:01:09 GMT</pubDate></item><item><title>oskar commented on Unprofessional code, take II</title><description>Just one unrelated question: Why is it 
if (a.HasWhereClause) 
?
Or is it just the renderer that have removed the "!"?</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment36</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment36</guid><pubDate>Wed, 18 Jul 2012 06:29:47 GMT</pubDate></item><item><title>Icer commented on Unprofessional code, take II</title><description>I think the implementation whether the index shall be returned should be decided in the abstractViewGenerator, so that the consumer of the abstractViewGenerator does not need to know about all the implementation details.

Result would be something like:
var abstractViewGenerator = database.IndexDefinitionStorage.GetViewGenerator(indexName);
if(absctractViewGenerator == null)
{return false;}
if(!abstractViewGenerator.FullfillsSomeConditions())
{return false;}
return true;

This makes the code much more readable and the logic is encapsulated in the class that knows what to do. :)
</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment35</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment35</guid><pubDate>Mon, 16 Jul 2012 09:32:51 GMT</pubDate></item><item><title>Douglas commented on Unprofessional code, take II</title><description>I feel it is missing some logging/tracing </description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment34</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment34</guid><pubDate>Mon, 16 Jul 2012 03:48:09 GMT</pubDate></item><item><title>Andrea Balducci commented on Unprofessional code, take II</title><description>and Rule should be something with business meaning instead of a summary of the filter implementation</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment33</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment33</guid><pubDate>Sun, 15 Jul 2012 08:16:09 GMT</pubDate></item><item><title>Andrea Balducci commented on Unprofessional code, take II</title><description>In my code would be (line 55) .Where(i =&gt; IsIndexMatchingRule1AndRule2AndSoOn..
I've to read in a simple way what the code is supposed to do, it's all about maintainability</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment32</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment32</guid><pubDate>Sun, 15 Jul 2012 08:07:58 GMT</pubDate></item><item><title>Ayende Rahien commented on Unprofessional code, take II</title><description>Nadav,
There is a difference between BAD code and unprofessional code.</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment31</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment31</guid><pubDate>Sun, 15 Jul 2012 07:01:31 GMT</pubDate></item><item><title>Nadav commented on Unprofessional code, take II</title><description>I gotta say that both examples are not that unprofessional, and I think you're using this term too freely. I've seen much much worse examples, like hundreds of pl-sql/t-sql statements, logic in triggers, etc.

Talking about unprofessional code, here's one of mine:
#warning Busy Wait!! use auto reset event
            while (paused) { } 
</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment30</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment30</guid><pubDate>Sat, 14 Jul 2012 21:01:40 GMT</pubDate></item><item><title>Victor Kornov commented on Unprofessional code, take II</title><description>@Ken Egozi, +1

The code screams for Refactor -&gt; Extract Method.</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment29</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment29</guid><pubDate>Sat, 14 Jul 2012 01:49:58 GMT</pubDate></item><item><title>David commented on Unprofessional code, take II</title><description>You don't get automatic function documentation for free if it's buried in a lambda within a body - better to relegate the predicate to it's own method.</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment28</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment28</guid><pubDate>Fri, 13 Jul 2012 23:41:03 GMT</pubDate></item><item><title>Tim Burga commented on Unprofessional code, take II</title><description>Agree with the diagnosis but not the solutions. I'd probably push the logic further back than just the abstractViewGenerator.. perhaps by adding a GetIndexNamesForEntity(entityName) method to IndexDefinitionStorage.</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment27</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment27</guid><pubDate>Fri, 13 Jul 2012 19:37:47 GMT</pubDate></item><item><title>Ken Egozi commented on Unprofessional code, take II</title><description>Obvious - the code is cut in the righthand side, so it would probably not compile</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment26</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment26</guid><pubDate>Fri, 13 Jul 2012 17:23:05 GMT</pubDate></item><item><title>Slava commented on Unprofessional code, take II</title><description>Logic backed in into IFs - unverifiable by compiler or runtime.
No one except you would be able to verify it. You would forget it sooner or later.
Its a sin to use staticly typed language i totaly untyped way. 
It probably would be faster and safer to turn this code into composable functions in some untype language as Javascript. :)

Good solution "might be" to use typed Expression trees (or just typed dispatch). Not only you would gain guarantees of compiler, logic backed into types - readable and self documenting,  you would also beneft in live support testing as well, since you would be able to easily put hooks to construct and inject your logic into expression tree dynamicly while still enoying safety of types
  </description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment25</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment25</guid><pubDate>Fri, 13 Jul 2012 17:18:11 GMT</pubDate></item><item><title>jg commented on Unprofessional code, take II</title><description>It has an awful lot of logic and I can't see the point of it immediately, so I would personally prefer it to be in a method that told me why all this logic is being performed, although having said that it may well be the implementation of said method given it returns the results.

I would guess the primary reason you say this is unprofessional is that if something showed up/didn't show in the results that was expected there is no easy way to find out (without debugging) why it is/isn't in the result set.
</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment24</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment24</guid><pubDate>Fri, 13 Jul 2012 17:02:59 GMT</pubDate></item><item><title>nick commented on Unprofessional code, take II</title><description>Sorry mate. You just didn't abstract your database underneath enough layers.

Totally fucking shoddy.</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment23</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment23</guid><pubDate>Fri, 13 Jul 2012 15:53:20 GMT</pubDate></item><item><title>Marcus Swope commented on Unprofessional code, take II</title><description>@Petr I agree, it should have been text so that we could copy-paste it ;-)</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment22</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment22</guid><pubDate>Fri, 13 Jul 2012 13:34:33 GMT</pubDate></item><item><title>Sam Naseri commented on Unprofessional code, take II</title><description>In snapshot, all the return statements are returning false value, so the where method basically is filtering out all the items and will return an empty sequence. Unless the side effect was desired this code is actually doing nothing expect than return database.IndexDefinitionStorage.IndexNames.Where(i=&gt;false)

But it seems that there is more code later.</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment21</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment21</guid><pubDate>Fri, 13 Jul 2012 13:23:22 GMT</pubDate></item><item><title>Rémi BOURGAREL commented on Unprofessional code, take II</title><description>Six line of comments ! </description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment20</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment20</guid><pubDate>Fri, 13 Jul 2012 12:50:27 GMT</pubDate></item><item><title>Matt Warren commented on Unprofessional code, take II</title><description>dacanetdev &amp; victor,

Unfortunately the first line inside the Where(..) statement is obscured, it reads:

var abstractViewGenerator = database.IndexDefinitionStorage.GetViewGenerator(indexName);

So indexName does get used ;-)</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment19</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment19</guid><pubDate>Fri, 13 Jul 2012 12:16:13 GMT</pubDate></item><item><title>Martin Lj commented on Unprofessional code, take II</title><description>Feature envy on abstractViewGenerator, use Tell don't Ask</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment18</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment18</guid><pubDate>Fri, 13 Jul 2012 12:12:31 GMT</pubDate></item><item><title>James L commented on Unprofessional code, take II</title><description>Too much green writing.  I'd extract methods with descriptive names</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment17</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment17</guid><pubDate>Fri, 13 Jul 2012 11:54:10 GMT</pubDate></item><item><title>@dacanetdev commented on Unprofessional code, take II</title><description>Where are you using indexName inside the lambda expression?</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment16</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment16</guid><pubDate>Fri, 13 Jul 2012 11:49:23 GMT</pubDate></item><item><title>Michael Chandler commented on Unprofessional code, take II</title><description>No logging?</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment15</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment15</guid><pubDate>Fri, 13 Jul 2012 11:39:37 GMT</pubDate></item><item><title>Radek Falhar commented on Unprofessional code, take II</title><description>I agree with Nieve. The whole thing looks like it only works with abstract view generator and should be refactored as it's method.</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment14</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment14</guid><pubDate>Fri, 13 Jul 2012 10:53:31 GMT</pubDate></item><item><title>Petr K. commented on Unprofessional code, take II</title><description>In the first place, posting code as a screenshot is what I call unprofessional..</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment13</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment13</guid><pubDate>Fri, 13 Jul 2012 10:43:43 GMT</pubDate></item><item><title>Ayende Rahien commented on Unprofessional code, take II</title><description>Tomas,
Why? It will still have the line number</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment12</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment12</guid><pubDate>Fri, 13 Jul 2012 10:33:33 GMT</pubDate></item><item><title>Olcay Seker commented on Unprofessional code, take II</title><description>it seems that you check every property of abstractViewGenerator. </description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment11</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment11</guid><pubDate>Fri, 13 Jul 2012 10:11:26 GMT</pubDate></item><item><title>Victor commented on Unprofessional code, take II</title><description>I dont see the point of all the checks done inside the Where clause. Are they related to indexName at all?
If they are not they should be outside the Where clause so they get executed only once...</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment10</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment10</guid><pubDate>Fri, 13 Jul 2012 10:04:17 GMT</pubDate></item><item><title>Ender commented on Unprofessional code, take II</title><description>IMHO this logic should be in a view generator.</description><link>http://ayende.com/156993/unprofessional-code-take-ii#comment9</link><guid>http://ayende.com/156993/unprofessional-code-take-ii#comment9</guid><pubDate>Fri, 13 Jul 2012 10:02:02 GMT</pubDate></item></channel></rss>