﻿<?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>Paul Stovell commented on Code review WTF, number N</title><description>@Markus:
  
  
class LogHelper 
  
{
  
    public static void Warn(Exception ex, string format, params object[] args) 
  
{
  
 Logger.WarnFormat(ex, format, args);
  
while (ex.InnerException != null)
  
{
  
ex = ex.InnerException;
  
Logger.Info("Inner Exception", ex);
  
}
  
    }
  
}
  
  
Now in the many places you use that code, you can have:
  
  
try
  
{
  
ActiveRecordMediator&lt;Foo&gt;.Save(foo);
  
}
  
catch (Exception ex)
  
{
  
LogHelper.Log("Error saving Foo {0}", foo.Name, ex);
  
}
  
}
  
  
There are thousands of libraries which require multiple lines to do something. There's no reason you should write those multiple lines twice. 
</description><link>http://ayende.com/2949/code-review-wtf-number-n#comment10</link><guid>http://ayende.com/2949/code-review-wtf-number-n#comment10</guid><pubDate>Tue, 13 Nov 2007 23:15:33 GMT</pubDate></item><item><title>Markus Zywitza commented on Code review WTF, number N</title><description>Windsor's LoggingFacility with loggingApi="console" obviously doesn't.
</description><link>http://ayende.com/2949/code-review-wtf-number-n#comment9</link><guid>http://ayende.com/2949/code-review-wtf-number-n#comment9</guid><pubDate>Tue, 13 Nov 2007 15:08:56 GMT</pubDate></item><item><title>Ayende Rahien commented on Code review WTF, number N</title><description>Well, most of the logging frameworks that I am aware of will handle this correctly. 
</description><link>http://ayende.com/2949/code-review-wtf-number-n#comment8</link><guid>http://ayende.com/2949/code-review-wtf-number-n#comment8</guid><pubDate>Tue, 13 Nov 2007 14:58:26 GMT</pubDate></item><item><title>Markus Zywitza commented on Code review WTF, number N</title><description>&gt;What is Logging? 
  
  
No special product, I simply wrote it with a capital letter because I'm accustomed to that practice. German language capitalizes all nouns, hence "Logging" instead of logging.
</description><link>http://ayende.com/2949/code-review-wtf-number-n#comment7</link><guid>http://ayende.com/2949/code-review-wtf-number-n#comment7</guid><pubDate>Tue, 13 Nov 2007 14:46:57 GMT</pubDate></item><item><title>Ayende Rahien commented on Code review WTF, number N</title><description>What is Logging?
</description><link>http://ayende.com/2949/code-review-wtf-number-n#comment6</link><guid>http://ayende.com/2949/code-review-wtf-number-n#comment6</guid><pubDate>Tue, 13 Nov 2007 14:40:47 GMT</pubDate></item><item><title>Markus Zywitza commented on Code review WTF, number N</title><description>Hmm, it seems that the fact that I always use Logging now avenges. Perhaps I should have just used 
  
Console.WriteLine(exception) 
  
:-(
</description><link>http://ayende.com/2949/code-review-wtf-number-n#comment5</link><guid>http://ayende.com/2949/code-review-wtf-number-n#comment5</guid><pubDate>Tue, 13 Nov 2007 14:39:43 GMT</pubDate></item><item><title>Ayende Rahien commented on Code review WTF, number N</title><description>Markus, is there a reason that you are doing it this way?
  
ex.ToString() gives you the inner exception as well, after all
</description><link>http://ayende.com/2949/code-review-wtf-number-n#comment4</link><guid>http://ayende.com/2949/code-review-wtf-number-n#comment4</guid><pubDate>Tue, 13 Nov 2007 14:18:52 GMT</pubDate></item><item><title>Markus Zywitza commented on Code review WTF, number N</title><description>&lt;pre&gt;
  
try
  
{
  
	ActiveRecordMediator&lt;Foo&gt;.Save(foo);
  
}
  
catch (Exception ex)
  
{
  
	Logger.WarnFormat(ex, "Error saving Foo {0}", foo.Name);
  
	while (ex.InnerException != null)
  
	{
  
		ex = ex.InnerException;
  
		Logger.Info("Inner Exception", ex);
  
	}
  
}
  
&lt;/pre&gt;
  
If you count the brace lines, it's 6 lines for the exception, too. But absolute necessary unless 
  
Castle.ActiveRecord.Framework.ActiveRecordException: Could not perform Save for Foo at ... in ... 
  
is enough for you to see the error's cause, which isn't the case for me.
</description><link>http://ayende.com/2949/code-review-wtf-number-n#comment3</link><guid>http://ayende.com/2949/code-review-wtf-number-n#comment3</guid><pubDate>Tue, 13 Nov 2007 14:10:41 GMT</pubDate></item><item><title>Grimace of Despair commented on Code review WTF, number N</title><description>"Using a naming convention where the company name is prefixed to all local variables"
  
  
I've witnessed a Database that was prefixed with the _DEVELOPERS_ initials, as were all tables in it... 
  
  
I still shiver while writing this.
</description><link>http://ayende.com/2949/code-review-wtf-number-n#comment2</link><guid>http://ayende.com/2949/code-review-wtf-number-n#comment2</guid><pubDate>Tue, 13 Nov 2007 11:49:10 GMT</pubDate></item><item><title>Paul Stovell commented on Code review WTF, number N</title><description>One subject in basic pure math that I wish all developers would take is factorization - taking an equation, recognising and removing the duplicates and simplifying. 
  
  
I still can't fathom how a developer can see the same thing over and over again - like 6 lines of code repeated every single time an exception needs to be logged - and not recognize that they can factor it out. 
  
  
Paul
</description><link>http://ayende.com/2949/code-review-wtf-number-n#comment1</link><guid>http://ayende.com/2949/code-review-wtf-number-n#comment1</guid><pubDate>Tue, 13 Nov 2007 11:46:19 GMT</pubDate></item></channel></rss>