﻿<?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>pd commented on Defensive coding is your friend</title><description>Just wondering...Ayende writing fragile tests? This is not best practice.</description><link>http://ayende.com/160898/defensive-coding-is-your-friend#comment9</link><guid>http://ayende.com/160898/defensive-coding-is-your-friend#comment9</guid><pubDate>Fri, 15 Feb 2013 12:18:40 GMT</pubDate></item><item><title>Janus commented on Defensive coding is your friend</title><description>Ayende, is that you?....</description><link>http://ayende.com/160898/defensive-coding-is-your-friend#comment8</link><guid>http://ayende.com/160898/defensive-coding-is-your-friend#comment8</guid><pubDate>Wed, 13 Feb 2013 08:28:22 GMT</pubDate></item><item><title>Daniel Wonisch commented on Defensive coding is your friend</title><description>Still this seems to me as a nasty workaround instead of a real solution, what might be OK for test code but wouldn't be acceptable in production code.

@Daniel: I have to be on Serhiy side of view. Since you do not want the developer to enable or disable fiddler all the time, but let the system take the decision for you, a better signature for that method would be GetFiddlerUrlOrDefault().
</description><link>http://ayende.com/160898/defensive-coding-is-your-friend#comment7</link><guid>http://ayende.com/160898/defensive-coding-is-your-friend#comment7</guid><pubDate>Tue, 12 Feb 2013 19:46:13 GMT</pubDate></item><item><title>Duke commented on Defensive coding is your friend</title><description>Mmmm 

Now the code is smart enough to not fail the test if we didn’t do things right.

Is that really a good thing?  It doesn't sound it.

Feels like the sort of thing which could lead to false positives, thinking you were actually testing something when internally it was circumventing it.  </description><link>http://ayende.com/160898/defensive-coding-is-your-friend#comment6</link><guid>http://ayende.com/160898/defensive-coding-is-your-friend#comment6</guid><pubDate>Tue, 12 Feb 2013 15:44:55 GMT</pubDate></item><item><title>Daniel Lang commented on Defensive coding is your friend</title><description>@Serhiy, this is why you can and should use named parameters in these cases, like GetServerUrl(fiddler:true)</description><link>http://ayende.com/160898/defensive-coding-is-your-friend#comment5</link><guid>http://ayende.com/160898/defensive-coding-is-your-friend#comment5</guid><pubDate>Tue, 12 Feb 2013 15:09:29 GMT</pubDate></item><item><title>Serhiy Kalinets commented on Defensive coding is your friend</title><description>bool args do not add clarity to the code. When you catch GetServerUrl(true) in the code it may be tricky to figure out what that true means without looking at method signature.</description><link>http://ayende.com/160898/defensive-coding-is-your-friend#comment4</link><guid>http://ayende.com/160898/defensive-coding-is-your-friend#comment4</guid><pubDate>Tue, 12 Feb 2013 14:01:13 GMT</pubDate></item><item><title>Gilligan commented on Defensive coding is your friend</title><description>I did a similar thing recently where I was testing seeding the database. This meant destroying and rebuilding it from NHibernate. However the config file was pointing to the QA database so it got wiped and needed to be restored from backup. Now I have an assertion in TestInitialize that ensures the database is local before seeding it with test data.  </description><link>http://ayende.com/160898/defensive-coding-is-your-friend#comment3</link><guid>http://ayende.com/160898/defensive-coding-is-your-friend#comment3</guid><pubDate>Tue, 12 Feb 2013 12:04:57 GMT</pubDate></item><item><title>Jonas commented on Defensive coding is your friend</title><description>I wouldn't call this defensive coding. You created testable code WAY different.

Defensive coding IMHO is ONLY EVIL... But we migh mean different things,.
To me defensive coding is what Frank is describing as paranoid coding :)

/Jonas</description><link>http://ayende.com/160898/defensive-coding-is-your-friend#comment2</link><guid>http://ayende.com/160898/defensive-coding-is-your-friend#comment2</guid><pubDate>Tue, 12 Feb 2013 11:42:09 GMT</pubDate></item><item><title>Frank Quednau commented on Defensive coding is your friend</title><description>As with every good advice, there is the evil counterpart: paranoid coding, when you litter your code with excessive null checks on things that cannot be null, catch exceptions you cannot handle, etc.</description><link>http://ayende.com/160898/defensive-coding-is-your-friend#comment1</link><guid>http://ayende.com/160898/defensive-coding-is-your-friend#comment1</guid><pubDate>Tue, 12 Feb 2013 11:23:30 GMT</pubDate></item></channel></rss>