<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>{(something&#124;&#124;other).soft()} &#187; General</title>
	<atom:link href="http://www.somethingorothersoft.com/category/general/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.somethingorothersoft.com</link>
	<description>About Software Development And Other Stuff By Igor Zevaka</description>
	<lastBuildDate>Fri, 18 Jun 2010 00:15:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Converting an Expression to a compiled Lambda</title>
		<link>http://www.somethingorothersoft.com/2010/06/18/converting-an-expression-to-a-compiled-lambda/</link>
		<comments>http://www.somethingorothersoft.com/2010/06/18/converting-an-expression-to-a-compiled-lambda/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 23:45:08 +0000</pubDate>
		<dc:creator>igor</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[expressions]]></category>
		<category><![CDATA[lamdbas]]></category>

		<guid isPermaLink="false">http://www.somethingorothersoft.com/?p=398</guid>
		<description><![CDATA[A quick guide on how to convert an expression to a compiled lambda.]]></description>
			<content:encoded><![CDATA[<h3>Compiling an expression to a lambda</h3>

<p>Today I had to convert a binary expression to a lambda and then use in a where clause on a collection. Easy enough, I thought, make an <code>ExpressionLambda</code>, compile it, substitute it into the where clause, no worries.</p>

<p>This is the first cut of the code:</p>

<div>
<pre class="brush: csharp;">

public class ClassWithProperties {
    public string Prop { get; set; }
}

static void ExpressionCrashes() {

    var expr = Expression.Equal(Expression.Property(Expression.Variable(typeof(ClassWithProperties)), &quot;Prop&quot;), Expression.Constant(&quot;value2&quot;));

    var props = new[] { Expression.Parameter(typeof(ClassWithProperties)) };
    //Throws &lt;variable '' of type 'SOCSTest.ClassWithProperties' referenced from scope '', but it is not defined&gt;
    var lambda = Expression.Lambda&lt;Func&lt;ClassWithProperties, bool&gt;&gt;(expr, props).Compile();

    var items = new List&lt;ClassWithProperties&gt; { 
        new ClassWithProperties{Prop = &quot;value1&quot;},
        new ClassWithProperties{Prop = &quot;value2&quot;},
        new ClassWithProperties{Prop = &quot;value2&quot;}
    };

    //Should return &lt;&quot;value2&quot;, &quot;value2&quot;&gt;
    items.Where(lambda);
}

</pre>
</div>

<p>The expression is a basic one &#8211; it calls an equality comparison on a property off an object and a constant. It is equivalent to this:</p>

<div>
<pre class="brush: csharp;">
value.Prop == &quot;value2&quot;
//Where value is a parameter of type ClassWithProperties
</pre>
</div>

<p>Googling for this exception and just general expression and lambda stuff kinda hints at people having the same problem as I am but with no fast solution. It was Jon Skeet&#8217;s <a href="http://stackoverflow.com/questions/1574427/lambda-parameter-not-in-scope-while-building-binary-lambda-expression/1574455#1574455">answer to question I didn&#8217;t understand</a> on StackOverflow that finally put me onto the right track.</p>

<p>In order to compile a lambda from an expression, you need to provide <strong>all instances of <code>ParameterExpression</code></strong> that appear in the expression tree when creating a lambda expressionn (i.e. when calling <code>Expression.Lambda&lt;T&gt;(Expression, params ParameterExpression[])</code>). The Expression engine will not match types and names parameters in an expression &#8211; as far as it&#8217;s concerned different instances of <code>ParameterExpression</code> are discrete parameters.</p>

<p>Rewriting the above code yields something that doesn&#8217;t crash:</p>

<div>
<pre class="brush: csharp;">
static void ExpressionWorks() {
    var variable = Expression.Variable(typeof(ClassWithProperties));
    var expr = Expression.Equal(Expression.Property(variable, &quot;Prop&quot;), Expression.Constant(&quot;value2&quot;));

    var props = new []{ variable };
    var lambda = Expression.Lambda&lt;Func&lt;ClassWithProperties, bool&gt;&gt;(expr, props).Compile();

    var items = new List&lt;ClassWithProperties&gt; { 
        new ClassWithProperties{Prop = &quot;value1&quot;},
        new ClassWithProperties{Prop = &quot;value2&quot;},
        new ClassWithProperties{Prop = &quot;value2&quot;}
    };

    //Returns &lt;&quot;value2&quot;, &quot;value2&quot;&gt;
    items.Where(lambda);
}
</pre>
</div>

<p>As you can see, we reused the instance <code>variable</code> in both expression declaration and <code>Expression.Lambda</code> call. Everything works fine now.</p>

<h3>Getting the parameters from Expression at runtime</h3>

<p>My situation was such as that I had to deal with an already created expression. So I couldn&#8217;t simply take the variable parameters that are used to create an expression and reuse them when creating a lambda. The solution was to traverse the expression tree and get a list of all the <code>ParameterExpression</code> instances that are contained in the expression and pass those to <code>Lambda</code> function.</p>

<p>Luckily, <a href="http://msdn.microsoft.com/en-us/library/bb546136%28v=VS.90%29.aspx"><code>ExpressionVisitor</code></a> API provides an easy way to achieve this. All you have to do is inherit from <code>ExpressionVisitor</code> and implement one function to trap all the goodies we need:</p>

<div>
<pre class="brush: csharp;">
public class ParameterVisitor : ExpressionVisitor{

    List&lt;ParameterExpression&gt; m_Parameters;

    public IEnumerable&lt;ParameterExpression&gt; GetParameters(Expression expr) {
        m_Parameters = new List&lt;ParameterExpression&gt;();
        Visit(expr);
        return m_Parameters;
    }
        
    protected override System.Linq.Expressions.Expression VisitParameter(System.Linq.Expressions.ParameterExpression p) {

        if(!m_Parameters.Contains(p))
            m_Parameters.Add(p);
            
        return base.VisitParameter(p);
    }
}
</pre>
</div>

<p>We can even create an extension method to hide all complexity of creating a lambda:</p>

<div>
<pre class="brush: csharp;">
public static Func&lt;TSource, TResult&gt; CreateLambda&lt;TSource, TResult&gt;(this Expression expression) {
    var visitor = new Bluecap4.Core.Expressions.ParameterVisitor();
    var parameters = visitor.GetParameters(expression);
            
    return Expression.Lambda&lt;Func&lt;TSource, TResult&gt;&gt;(expression, parameters).Compile();
}
//Usage
static void ExpressionWorks() {
    var expr = Expression.Equal(Expression.Property(Expression.Variable(typeof(ClassWithProperties)), &quot;Prop&quot;), Expression.Constant(&quot;value2&quot;));

    var items = new List&lt;ClassWithProperties&gt; { 
        new ClassWithProperties{Prop = &quot;value1&quot;},
        new ClassWithProperties{Prop = &quot;value2&quot;},
        new ClassWithProperties{Prop = &quot;value2&quot;}
    };

    //Returns &lt;&quot;value2&quot;, &quot;value2&quot;&gt;
    items.Where(expr.CreateLambda&lt;Func&lt;ClassWithProperties,bool&gt;&gt;());
}
</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.somethingorothersoft.com/2010/06/18/converting-an-expression-to-a-compiled-lambda/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A few things you might not know about System.Nullable</title>
		<link>http://www.somethingorothersoft.com/2010/05/29/a-few-things-you-might-not-know-about-system-nullable/</link>
		<comments>http://www.somethingorothersoft.com/2010/05/29/a-few-things-you-might-not-know-about-system-nullable/#comments</comments>
		<pubDate>Sat, 29 May 2010 13:59:24 +0000</pubDate>
		<dc:creator>igor</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.somethingorothersoft.com/?p=385</guid>
		<description><![CDATA[There is plenty of information about Nullable&#60;T&#62; type out there and how to use it. There are, however a few tidbits that are not quite as obvious at first glance. Nullable is a value type It&#8217;s a struct that can be null. The only reason why int? intVal = null; compiles is because C# compiler <a href="http://www.somethingorothersoft.com/2010/05/29/a-few-things-you-might-not-know-about-system-nullable/" rel="bookmark" title="Read on...">[...]</a>]]></description>
			<content:encoded><![CDATA[<p>There is plenty of information about <code>Nullable&lt;T&gt;</code> type out there and how to use it. There are, however a few tidbits that are not quite as obvious at first glance.</p>

<h1>Nullable<T> is a value type</h1>

<p>It&#8217;s a struct that can be null. The only reason why <code>int? intVal = null;</code> compiles is because C# compiler supports nullable types. You <strong>cannot</strong> define the same kind of struct yourself.</p>

<p>The decision to make <code>Nullable&lt;T&gt;</code> a value type actually makes sense if you think about it. Calling its member methods and properties will always succeed, i.e. NullReferenceException will never be thrown. This gurantees that <code>HasValue</code> never throws a NullReferenceException.</p>

<h1>Comparison to null</h1>

<p>Under the hood, the compiler, in fact translates comparison to null to a call to HasValue. The below MSIL demonstrates that:</p>

<div>
<pre class="brush: csharp;">
    .locals init ([0] valuetype [mscorlib]System.Nullable`1&lt;int32&gt; 'value',
           [1] bool hasvalue,
           [2] bool hasvalue2)

    //int? value = null;
    IL_0001:  ldloca.s   'value'
    IL_0003:  initobj    valuetype [mscorlib]System.Nullable`1&lt;int32&gt;
    //bool hasvalue = value.HasValue;
    IL_0009:  ldloca.s   'value'
    IL_000b:  call       instance bool valuetype [mscorlib]System.Nullable`1&lt;int32&gt;::get_HasValue()
    IL_0010:  stloc.1
    //bool hasvalue2 = value != null;
    IL_0011:  ldloca.s   'value' //loads a variable onto evaluation stack
    IL_0013:  call       instance bool valuetype [mscorlib]System.Nullable`1&lt;int32&gt;::get_HasValue() //calls HasValue
    IL_001b:  stloc.2 //Stores the result in location 2 (hasvalue2)
</pre>
</div>

<p>As you can see the generated IL for <code>hasvalue = value.HasValue</code> and <code>hasvalue2 = value != null</code> are identical.</p>

<h1>null Assignment</h1>

<p>Also from above code you can see that assigning null to a nullable value is the same as calling the parameterless contructor (which all value types have).</p>

<h1>Ternary operator</h1>

<p>C# compiler also does special things with ternary operator for nullable types. The following code compiles:</p>

<div>
<pre class="brush: csharp;">
int? nullableIntVal = 4;
int intVal = nullableIntVal ?? -1;
</pre>
</div>

<p>The above is just syntactic sugar for calling <code>HasValue</code> and if it&#8217;s true calling GetValueOrDefault(). The compiler actually generates a temporary variable to call <code>HasValue</code> off in both Release and Debug modes. Not sure why that is. Below code illustrates the equivalent C# code to what the compiler generates for ternary operator.</p>

<div>
<pre class="brush: csharp;">
int? nullableIntVal = 4;
int? temp = nullableIntVal;
int intVal = temp.HasValue ?? temp.GetValueOrDefault() : -1;
</pre>
</div>

<h1>Summary</h1>

<p><code>Nullable&lt;T&gt;</code> is a special value type that has support from C# compiler to allow the following:</p>

<ul>
<li><code>null</code> assignment  &#8211; under the hood: calling defualt constructor.</li>
<li><code>null</code> comparison &#8211; under the hood: calling <code>HasValue</code> property.</li>
<li>ternary operator <code>??</code> &#8211; under the hood: calling <code>HasValue</code> and conditionally <code>GetValueOrDefault</code>.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.somethingorothersoft.com/2010/05/29/a-few-things-you-might-not-know-about-system-nullable/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Unit Tests As A Refactoring Tool</title>
		<link>http://www.somethingorothersoft.com/2010/02/20/unit-tests-as-a-refactoring-tool/</link>
		<comments>http://www.somethingorothersoft.com/2010/02/20/unit-tests-as-a-refactoring-tool/#comments</comments>
		<pubDate>Sat, 20 Feb 2010 07:23:34 +0000</pubDate>
		<dc:creator>igor</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[unit-testing]]></category>

		<guid isPermaLink="false">http://www.somethingorothersoft.com/?p=283</guid>
		<description><![CDATA[So I have this class that is a bit too fat and has no unit tests. It&#8217;s way overdue for a clean up. I thought I would investigate how to refactor with unit tests. Application The application in question is a fairly normal case of a business DSL where the domain rules are expressed in <a href="http://www.somethingorothersoft.com/2010/02/20/unit-tests-as-a-refactoring-tool/" rel="bookmark" title="Read on...">[...]</a>]]></description>
			<content:encoded><![CDATA[<p>So I have this class that is a bit too fat and has no unit tests. It&#8217;s way overdue for a clean up. I thought I would investigate how to refactor with unit tests.</p>

<h3>Application</h3>

<p>The application in question is a fairly normal case of a business DSL where the domain rules are expressed in XML and the compiler generates an application for different platforms (web, mobile web, PDA, WPF). Code is written in C#, tested with MbUnit v.3 and NMock2.</p>

<p>This particular class parses XML and generates JSON to be later consumed by ExtJS library. The JSON is a declaritive form of the control that users will eventually see. This control is complicated and has many options. Hence the fatness.</p>

<h3>Enter the unit tests</h3>

<p>Now, unit tests are touted to be great for refactoring. They are. The usual approach is to write the tests, make sure they pass, then refactor and make sure the tests don&#8217;t break. Well, I want to take it one step further and let the writing of the tests guide the refactoring.</p>

<p>Thoroughly unit tested code tends to have really good code smells. This is mainly due to fact that in order to test all aspects of a large block of code, you must isolate all of its constituents. This is evident in all projects that are written in a TDD way. They are all very modular and modular is good(I think :-) ).</p>

<p>So my goal here is just simply write the unit tests and see where it takes me. I would imagine that just by making the code testable, it will become a little bit better.</p>

<p>I never invisaged this to become a full blown article, but now that I am here, lets introduce some numbers to make this more scientific. I will be using Microsoft Team Studio Analysis Tools throughout the process. Here is a snapshot of what the class looks like at the start:</p>

<p><a href="http://www.somethingorothersoft.com/wp-content/uploads/2010/02/start.png"><img src="http://www.somethingorothersoft.com/wp-content/uploads/2010/02/start.png" alt="" title="start" width="808" height="173" class="alignnone size-full wp-image-284" /></a></p>

<p>As you can see the <code>Build</code> method is too big &#8211; 250 lines. This is bad. It&#8217;s one of those <code>DoIt</code> methods that does everything.</p>

<h3>First refactor</h3>

<p>Alright, lets get cranking. Straight away I noticed that I was reading a particular bit of XML and making decisions based on the node contents. This particular functionality has already been abstracted away in another class, so I might as well use that class. So I just refactored that without writing any tests before or after. That&#8217;s pretty naughty :)) Lets make it proper and rip this code into another function so we can test it.</p>

<p>Starting from the top of the method I am looking at a bit of code that parses an atribute and calls a method that is defined in the base class depending on whether or not the attribute exists.</p>

<h3>Base class dependency</h3>

<p>Now refactoring that into a method is not a problem, the problem is isolating the call to the base class. There is case to be made for having the base class contain all the dependencies that are required for all of its subclasses, however, just by skimming the code it looks like a lot of the methods there are simply in one place for convinience. So this could potentially be a case of Inheritance vs. Composition. Lets start off by abstracting  this particular method into an interface and have our base derive from the interface. Then in our derived class we access that method through a reference to the interface, not implicitly.</p>

<p>This is what it looks like now:</p>

<div>
<pre class="brush: csharp;">
class Builder {
   public DoStuff(string blah){
      //impl
   }
}

class GridBuilder : Builder{
   public void Build() {
      var elem = Element.GetAttribute(&quot;Blah&quot;);
      DoStuff(blah);
   }
}
</pre>
</div>

<p>Let&#8217;s tweak it as described in the previous paragraph:</p>

<div>
<pre class="brush: csharp;">
interface IBuilder {
    DoStuff(string blah);
}

[code lang=&quot;csharp&quot;]
class Builder : IBuilder {
   [Obsolete]
   public DoStuff(string blah){
      //impl
   }
}

class GridBuilder {
   
   IBuilder _Builder;
   
   public GridBuilder() {
     _Builder = this;
   }
   
   public GridBuilder(IClientBuilder b) {
            m_ClientBuilder = b;
    }
   
   public void Build() {
      var elem = Element.GetAttribute(&quot;Blah&quot;);
      _Builder = DoStuff(blah);
   }
}
</pre>
</div>

<p>So what I have done is put that <code>DoStuff</code> into an interface and marked the implementation as Obolete. This is more out of convinience to get the compiler to show me where else this method is being used. Turns out this was the only case where it was used in <code>GridBuilder</code>. I could have just as well used text search, but hey, if there is a fancy compiler feature, why not use it? Notice that I also added a dependency constructor so I can compose <code>GridBuilder</code> in a unit test.</p>

<p>Let's make a unit test for this use of <code>DoStuff</code>. As I am doing that I realised that my base class is in a different assembly and required some code duplication from another test project to make the test not crash. The fact that I had to do that is a pretty bad, but my copying the common setup file and including it in my test project is even worse. We can come back to that later, lets concentrate on what we are doing now. Might as well use the <code>Obsolete</code> attribute to remind me to refactor the unit test later on.</p>

<h3>Finally, I can test <code>Build</code></h3>

<p>So, after a long time setting up <code>GridBuilder</code>'s dependencies I am finally here - the test runs. Lets review what I've achieved so far and have a peek at the metrics. So here is the summary of what was required just to make the test run:</p>

<ul>
<li>Two instances of referring to the base class have been abstractes into two interfaces.</li>
<li>Found a bug where if a required element is present but contains no nodes the builder crashes.</li>
<li>The test creates a total of three mock objects with a total of five <code>Stubs</code> and one <code>Expect</code>.</li>
<li>The test needs to pass in an Xml element with two elements and one atribute.</li>
<li>Found a small refactoring job that is not really related to the unit testing aspect of this excercise.</li>
</ul>

<p>Code metrics:</p>

<p><a href="http://www.somethingorothersoft.com/wp-content/uploads/2010/02/step1.png"><img src="http://www.somethingorothersoft.com/wp-content/uploads/2010/02/step1.png" alt="" title="step1" width="954" height="210" class="alignnone size-full wp-image-286" /></a></p>

<p>So I didn't get anywhere as far as most metrics are concerned, in fact I almost went backwards, if anything. Let's keep going. So now I have a unit test that runs the <code>Build</code> method lets keep trying to test more and more parts of it.</p>

<p>Before I go on, I would like to emphasize the fact that I had to create lots of mocks and pass in lots of dependencies just to make one method not crash. Here is the unit test. Definitely too much for ONE method:</p>

<div>
<pre class="brush: csharp;">

        [SetUp]
        public void Setup() {
            m_Mocks = new Mockery();
            m_Settings = new InlineBuilderSettings {
                Compiler = m_Mocks.NewMock&lt;IWebCompiler&gt;(),
                ComponentName = &quot;Test&quot;
            };
            //Used by setup method
            Stub.On(m_Settings.Compiler).GetProperty(&quot;ServerCompiler&quot;).Will(Return.Value(null));
            Stub.On(m_Settings.Compiler).GetProperty(&quot;ServerType&quot;).Will(Return.Value(typeof(Data.ServerAplication)));
        }
        
        [Test]
        public void BuildShouldCallRequireComponentWhenViewAttribute() {

            var iClientBuilder = m_Mocks.NewMock&lt;IClientBuilder&gt;();
            var iBuilder = m_Mocks.NewMock&lt;IWebBuilder&gt;();

            Builder builder = new Builder(iClientBuilder, iBuilder);
            m_Settings.Element = 
                new XElement(&quot;Grid&quot;, new XAttribute(&quot;View&quot;, &quot;test&quot;), 
                    new XElement(&quot;Source&quot;, new XAttribute(&quot;View&quot;, &quot;DataTest&quot;)),
                    new XElement(&quot;Fields&quot;));

            Expect.Once.On(iClientBuilder).Method(&quot;RequireComponent&quot;).With(&quot;test&quot;, m_Settings.Element).Will();
            Stub.On(iClientBuilder).Method(&quot;GetComponentInfo&quot;).Will(Return.Value(new ComponentInfo()));
            Stub.On(iBuilder).Method(&quot;AddConfig&quot;).Will();
            Stub.On(m_Settings.Compiler).Method(&quot;AddInclude&quot;).Will();
            
            builder.Setup(m_Settings);
            builder.Build();
        }
</pre>
</div>

<p>Realistically, in order to complete the build process we need all those dependencies. That's pretty fundamental. However, it should be possible to reduce the amount of dependencies ONE method has.</p>

<h3>Next refactor</h3>

<p>My next target was a reasonably self contained code block that I did "Extract Method" method on. Two more unit tests. Slight improvement in maintainability and complexity.</p>

<p><a href="http://www.somethingorothersoft.com/wp-content/uploads/2010/02/step2.png"><img src="http://www.somethingorothersoft.com/wp-content/uploads/2010/02/step2.png" alt="" title="step2" width="996" height="236" class="alignnone size-full wp-image-287" /></a></p>

<p>Next one is a big sucker. This block produces about 5 output objects that are dumped to JSON later on. I actually moved to another two classes. One to perform the build and another to store the output.</p>

<p><a href="http://www.somethingorothersoft.com/wp-content/uploads/2010/02/step3.png"><img src="http://www.somethingorothersoft.com/wp-content/uploads/2010/02/step3.png" alt="" title="step3" width="896" height="236" class="alignnone size-full wp-image-288" /></a></p>

<p>Good improvement on all counts. Lets keep splitting the Build method and writing tests for it. As I am doing this I decided to make the GridBuilder a namespace within a project. There are a number of classes in it by now, might as well contain them in a folder.</p>

<h3>Day later.</h3>

<p>I have somewhat abandoned refactoring GridBuilder as I found a whole bunch of other tightly coupled classes. The unit tests have proven to be a great tool exposing those dependencies. They also become usefull when the refactoring becomes non-trivial - i.e. goes beyond just moving a block of code out of a method.</p>

<p>This is what the class looked like once I finished with it:</p>

<p><a href="http://www.somethingorothersoft.com/wp-content/uploads/2010/02/step4.png"><img src="http://www.somethingorothersoft.com/wp-content/uploads/2010/02/step4.png" alt="" title="step4" width="975" height="230" class="alignnone size-full wp-image-289" /></a></p>

<p>Now that I ran out of time that I gave myself for this task I think I have a few notes for future.</p>

<ul>
<li>Parsing an XML collection is ugly and tends to get messy when things need to be addded to the inner loop. I think for this scenario I would need some sort of visitor pattern implemented so that you could add things to the inner loop without having to alter the loop itself.</li>
<li>Having implicit dependencies (like a dependency on a property of an actual dependency) totally breaks the unit tests. A situation where you create one mock and then have its method return another mock is a bit ridiculous.</li>
<li>A unit test for a monstrous method will too be monstrous. There is almost 1-to-1 relationship between how fat the method is and how fat its unit test is. I think that if one aims to make unit test simpler, the code under test will in turn become simpler.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.somethingorothersoft.com/2010/02/20/unit-tests-as-a-refactoring-tool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I Like Words &#8211; Or Introduction Into Functional Programming and F#.</title>
		<link>http://www.somethingorothersoft.com/2010/02/09/i-like-words-or-introduction-into-functional-programming-and-f/</link>
		<comments>http://www.somethingorothersoft.com/2010/02/09/i-like-words-or-introduction-into-functional-programming-and-f/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 07:11:56 +0000</pubDate>
		<dc:creator>igor</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[f#]]></category>
		<category><![CDATA[functional-programming]]></category>

		<guid isPermaLink="false">http://www.somethingorothersoft.com/?p=270</guid>
		<description><![CDATA[If you hoped to find some sort of functional programming introduction here you are sadly mistaken. This is MY introduction into such said programming. Or it is more like &#8220;I&#8217;ve read up on F#, my brain exploded and spilled out into this blog post&#8221;. I would like to start off by comparing programming languages to <a href="http://www.somethingorothersoft.com/2010/02/09/i-like-words-or-introduction-into-functional-programming-and-f/" rel="bookmark" title="Read on...">[...]</a>]]></description>
			<content:encoded><![CDATA[<p>If you hoped to find some sort of functional programming introduction here you are sadly mistaken. This is MY introduction into such said programming. Or it is more like &#8220;I&#8217;ve read up on F#, my brain exploded and spilled out into this blog post&#8221;.</p>

<p>I would like to start off by comparing programming languages to spoken languages. Most will agree that the comparison is fair. Programming languages bear most hallmarks of real life languages. There is syntax, grammar, dictionary, there are historical reasons for why the language the way it is, etc. Generally speaking one is most fluent in their native tongue and could deal with a couple of others. Similarly in programming you have your native language &#8211; C family, VB, Pascal, Ruby, Python, Perl, hieroglyphics(PHP) etc.</p>

<p>My native language is Russian and that&#8217;s what I grew up with. From a reasonalby early age I learnt English and was reasonably fluent in it as a second language. I would like to equate this SECOND language to your FIRST programming language. The similarity, for the sake of this post, is that you think in your native language and translate it into code. The process, as those who speak other tongues would know, is similar. You form what you want to say in your head, translate all the words into the other language, rearrange the sentence if the target language requies so and then produce the output.</p>

<p>As with a second spoken language, writing programs eventually becomes second nature. Enter third (spoken) langague, e.g. French, that I learned in school. I found that my brain was stuck in this binary Russian/English mode and I could not add French to the mix, so my French was coming out very English like.</p>

<p>This is the problem I am facing with F#. It is SO compltely different that my C/C++/C#/Whatever-happy brain does not accept it. If comparing to spoken languages, it&#8217;s even further away from C than French is from English. It&#8217;s more like Japanese, where both the alphabet and the mindset are different.</p>

<p>So, coming back to the point of this dribble. I like words. I like the explicitness of procedural languages. I think it tends to follow how one thinks. <code>if</code> statements, <code>while</code> statements, assignment, parameter passing &#8211; they are all very logical.</p>

<p>My biggest hurdle understanding F# is the fact that the same syntax can be used for instantiation and matching. For example defining a function that takes a tuple with two members:</p>

<p><pre class="brush: fsharp;">let func (a, b) = printfn &quot;a: %d, b: %d&quot; a b;;</pre></p>

<p>The syntax is the same as when you define a tuple:</p>

<p><pre class="brush: fsharp;">let tuple = (4, 5);;</pre></p>

<p>Wheres a, say C++ would do something like this:</p>

<div>

<pre class="brush: cpp;">
Tuple&lt;int, int&gt; = new Tuple&lt;int, int&gt;(4,5);

void func(Tuple&lt;int, int&gt; tuple) {
}
</pre>
</div>

<p>F# seems to just use all these symbol operators for everything and I just can&#8217;t let go of my attachment to words. <code>List.Add</code> is logical, <code>[4;5;]@[6;7]</code> is less so, especially considering that the operands cound be either values or lists.</p>

<p>Speaking of words, here is some lingo that you will undoubttedly come across as you learn a functional programming language. The list is not complete and some words are not simple definitions, but quite complex concepts &#8211; like combinators &#8211; those will make your head hurt extra good :))</p>

<ul>
<li>High Order Function &#8211; Function that can take functions as parameters and/or return a function</li>
<li>Curried function &#8211; High Order Function that binds one or more of the parameters to a predetermined value and returns a function that takes less parameters.</li>
<li>Purity &#8211; Functions not having side effects &#8211; i.e. the function produces an output without chnaging the input or modifying state somewhere else. This normally invoves using immutable data structures and combinators.</li>
<li>Cons operator (<code>::</code>) &#8211; Adding an element to the beginning of the list.</li>
<li>Strictness &#8211; Evaluating parameters to the function before the function is evaluated.</li>
<li>combinator &#8211; High order function that has no free variables. Short version is that this function only operates on its parameters, not any other functions or values defined elsewhere.</li>
<li>Memoization &#8211; Remembering the result of a slow running function for future use (Caching).</li>
<li>Imperative programming &#8211; &#8220;normal&#8221; programming &#8211; i.e. Procedural, Object Orientated, etc.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.somethingorothersoft.com/2010/02/09/i-like-words-or-introduction-into-functional-programming-and-f/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>#iitrial Result &#8211; What&#8217;s Next?</title>
		<link>http://www.somethingorothersoft.com/2010/02/04/iitrial-result-whats-next/</link>
		<comments>http://www.somethingorothersoft.com/2010/02/04/iitrial-result-whats-next/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 01:16:57 +0000</pubDate>
		<dc:creator>igor</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[copyright]]></category>
		<category><![CDATA[iinet]]></category>

		<guid isPermaLink="false">http://www.somethingorothersoft.com/?p=261</guid>
		<description><![CDATA[Now that iiNet has won a a landmark court case, what does that mean for the future of Internet users in Australia?]]></description>
			<content:encoded><![CDATA[<p>Well the iiTrial result is a smashing win for the ISP and is the result that everyone hoped for. Even the most hopeful observers thought that the most likely outcome would be dilluted in some way (i.e. the &#8216;reasonable steps&#8217; would be for ISP to pass the notices on). A complete and annhilating defeat for the studios is the icing on the cake. The facts of the decision are available <a href="http://www.zdnet.com.au/news/communications/soa/Why-the-court-ruled-for-iiNet/0,130061791,339300823,00.htm">here</a>, <a href="http://itnews.com.au/News/166348,iinet-wins-film-industrys-case-torn-to-shreds.aspx">here</a> and <a href="http://www.smh.com.au/technology/technology-news/iinet-slays-hollywood-in-landmark-piracy-case-20100204-ndwr.html">here</a>.</p>

<p><strong>So, what does this mean for Australian bittorrenters?</strong></p>

<p>Well, for once it means a <strong>giant step back</strong> for the studios. As RIAA has discovered, filing individual lawsuits agaist filesharers is pretty bad PR. Such bad PR, that they, in fact, tried to spin that they no loger sue the individuals, which of course is <a href="http://www.techdirt.com/articles/20090504/0114014729.shtml">bogus</a>. All in all, the content rights holders are discovering that suing individuals got them nowhere.</p>

<p>So, in order to eradicate the &#8220;problem of file sharing&#8221; the studios see a number of options available to them (apart from the obvious &#8211; i.e. providing product people want to pay money for), in order of increasing perceived effectiveness:</p>

<ol>
<li>Suing individuals.</li>
<li>Send out notices to the ISP alerting them that infringement has occured an hope to scare some people off file sharing.</li>
<li>Making ISPs responsible for copyright infringement.</li>
</ol>

<p>So, going after individuals is ineffective and expensive. The holly grail of Big Content is number 3 though. They would love to make ISPs culpable for illegal file sharing. That&#8217;s what all the <a href="http://www.eff.org/deeplinks/2009/11/leaked-acta-internet-provisions-three-strikes-and-">three strikes laws attempts</a> are about. If the studios can make ISPs liable for user infringement, they hope that ISPs will police their networks, maybe even to the point of disabling BitTorrent. So far getting ISPs to kick users off the network required legislative support worldwide (i.e. France and Korea) as it is clearly in violation of safe harbour provisions.</p>

<p>AFACT decided to approach this from a different angle and set a precedent that it&#8217;s reasonable to kick off alleged infringers for repeated offences. They went after the easiest target &#8211; the big ISP that publicly stated that they do not send infringement notices to users. iiNet council even argued that AFACT <a href="http://forums.whirlpool.net.au/forum-replies.cfm?t=1296021&amp;p=5#r90">manufactured authorisation</a> by sending out notices to the ISP that they knew were not going to be acted upon in preparation for this very court case.</p>

<p>Going back to why this is a step back for AFACT. Now that iiNet is in the clear it is obvious that ISPs are under no obligation to pass infringement notices on. They might have been a scare tactic that somewhat worked (maybe on 10% of the people who received them). Now the studios don&#8217;t even have that. It was an all in game for the studios and they lost.</p>

<p>Of course AFACT will appeal, but they have lost a lot of momentum. Months, if not years worth of momentum. My prediction is that they will make a token effort in appealing and instead concentrate on lobbying for three strikes law.</p>

<p>So the <strong>next big thing</strong> in copyright in Australia is ACTA. DFAT has publicly come out and said that Australia is <a href="http://itnews.com.au/News/166308,no-three-strikes-rule-for-australian-isps.aspx">not going to implement three strikes laws</a>. I, however, do not trust them. Politicians and lobbyists involved in ACTA around the world have notoroiously been <a href="http://techdirt.com/articles/20100202/0216227999.shtml">blowing smoke about it</a>. I would take anything that anyone involved in a secret treaty negotiation with a grain of salt.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.somethingorothersoft.com/2010/02/04/iitrial-result-whats-next/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Double Dispatch &#8211; RTTI vs. Pure Vtable</title>
		<link>http://www.somethingorothersoft.com/2010/02/02/double-dispatch-rtti-vs-pure-vtable/</link>
		<comments>http://www.somethingorothersoft.com/2010/02/02/double-dispatch-rtti-vs-pure-vtable/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 22:16:03 +0000</pubDate>
		<dc:creator>igor</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[c++]]></category>

		<guid isPermaLink="false">http://www.somethingorothersoft.com/?p=235</guid>
		<description><![CDATA[As Jeremy Clarkson would say, I have been inundated with a request to performance test a dynamic_cast DD mechanism against the pure vtable one. The results surprised me, both in Debug and Release modes. So here is the dynamic_cast implementation: void c_rtti::foobar(a_rtti &#38; a2) { c_rtti* c_ = dynamic_cast&#60;c_rtti*&#62;(&#38;a2); if (c_) { ::foobar(*this,*c_); return; } <a href="http://www.somethingorothersoft.com/2010/02/02/double-dispatch-rtti-vs-pure-vtable/" rel="bookmark" title="Read on...">[...]</a>]]></description>
			<content:encoded><![CDATA[<p>As Jeremy Clarkson would say, I have been inundated with <a href="http://www.somethingorothersoft.com/2010/02/01/double-dispatch-without-rtti/comment-page-1/#comment-250">a request</a> to performance test a <code>dynamic_cast</code> DD mechanism against the <a href="http://www.somethingorothersoft.com/2010/02/01/double-dispatch-without-rtti/">pure vtable</a> one. The results surprised me, both in Debug and Release modes. So here is the <code>dynamic_cast</code> implementation:</p>

<div class="foo">
<pre class="brush: cpp;">
void c_rtti::foobar(a_rtti &amp; a2) {
   c_rtti* c_ = dynamic_cast&lt;c_rtti*&gt;(&amp;a2);
   if (c_) {
      ::foobar(*this,*c_);
      return;
   }
   b_rtti* b_ = dynamic_cast&lt;b_rtti*&gt;(&amp;a2);
   if (b_) {
      ::foobar(*b_, *this);
   }
}
</pre>
</div>

<p>I have used the most non-trivial case where the above function is called with <code>a2</code> parameter pointing to an instance of <code>b_rtti</code>, thus triggerring two dynamic casts. I used the same technique on the vtable implementation for consistency, although it doesn&#8217;t matter as the sequence of execution is the same for any combination of objects. The test ran for 4 million iterations.</p>

<p>Here is the test code:</p>

<div class="foo">
<pre class="brush: cpp;">
        a&amp; a_ = c();
        b bInstance;
        a&amp; b_ = bInstance;
        a_.foobar(b_);
</pre>
</div>

<p>Just to show what actually happens in both implementations, here are the sequence diagrams.</p>

<h4>vtable:</h4>

<p><a href="http://www.somethingorothersoft.com/wp-content/uploads/2010/02/vtable1.png"><img src="http://www.somethingorothersoft.com/wp-content/uploads/2010/02/vtable1.png" alt="" title="vtable" width="346" height="230" class="alignnone size-full wp-image-238" /></a></p>

<h4>dynamic_cast:</h4>

<p><a href="http://www.somethingorothersoft.com/wp-content/uploads/2010/02/rtti.png"><img src="http://www.somethingorothersoft.com/wp-content/uploads/2010/02/rtti.png" alt="" title="dynamic_cast Sequnce Diagram" width="254" height="304" class="alignnone size-full wp-image-236" /></a></p>

<h3>The results</h3>

<p>In debug mode, RTTI implementation is about 20% faster:</p>

<pre><code>No RTTI - 1685 milleseconds.
With RTTI - 1295 milleseconds.(23.15% faster)
</code></pre>

<p>So this is pretty insignificant in a real life application and I doubt it would come in the profiler. By my calculation there is about 100 clock cycles (on a 1Ghz CPU) difference between the two per call.</p>

<p>In Release mode things get interesting:</p>

<pre><code>No RTTI - 62 milleseconds.
With RTTI - 780 milleseconds.(-1158.06% faster)
</code></pre>

<p>The pure vtable version is ten times faster!!! Of course this again means very little in the real world. It&#8217;s worth noting that the RTTI verson is twice faster in Release mode. What is also interesting is that in Debug mode vtable is slower by 100 clock cycles, in release it&#8217;s faster by 200.</p>

<p>To summarise. The real life value of this performance analysis is zero. If you are Google and you had 100 PhDs design the program and another 100 wrote the library routines for it, doing this optimization will improve the performance by about 0.000001%. In any other case, this is textbook case of premature optimisation.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.somethingorothersoft.com/2010/02/02/double-dispatch-rtti-vs-pure-vtable/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Adding schemaLocation attribute to XElement in LINQ to SQL</title>
		<link>http://www.somethingorothersoft.com/2010/01/28/adding-schemalocation-attribute-to-xelement-in-linq-to-sql/</link>
		<comments>http://www.somethingorothersoft.com/2010/01/28/adding-schemalocation-attribute-to-xelement-in-linq-to-sql/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 21:31:36 +0000</pubDate>
		<dc:creator>igor</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.somethingorothersoft.com/?p=223</guid>
		<description><![CDATA[I have spent a bit of time trying to figure out how to generate an XML document with all the XML namespace paraphernalia &#8211; including schema location. I got stuck trying to create the xmlns:xsi attribute &#8211; LINQ to XML kept creating a namespace alias for me and calling it p1 like so: &#60;rootNode p1:xsi=&#34;http://www.w3.org/2001/XMLSchema-instance&#34; <a href="http://www.somethingorothersoft.com/2010/01/28/adding-schemalocation-attribute-to-xelement-in-linq-to-sql/" rel="bookmark" title="Read on...">[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I have spent a bit of time trying to figure out how to generate an XML document with all the XML namespace paraphernalia &#8211; including schema location. I got stuck trying to create the <code>xmlns:xsi</code> attribute &#8211; LINQ to XML kept creating a namespace alias for me and calling it <code>p1</code> like so:</p>

<p><pre class="brush: xml;">&lt;rootNode p1:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; p1=&quot;http://www.foo.bar&quot; xmlns=&quot;http://www.foo.bar&quot;&gt;
&lt;/rootNode&gt;</pre></p>

<p>Turns out the answer is pretty simple. I was correct in my assumption that in order to create a namespace alias one must simply add an attribute to the node. However the <code>xmlns</code> namespace is special and one cannot use the string <code>xmlns</code> or use the default namespace. Instead one must use <code>XNamespace.Xmlns</code> &#8211; like so: <code>new XAttribute(XNamespace.Xmlns + "xsi", "http://www.w3.org/2001/XMLSchema-instance")</code>. Here is complete code:</p>

<p><pre class="brush: csharp;">XNamespace xsi = XNamespace.Get(&quot;http://www.w3.org/2001/XMLSchema-instance&quot;);
            XNamespace defaultNamespace = XNamespace.Get(&quot;http://www.foo.bar&quot;);
            XElement root = new XElement(defaultNamespace + &quot;rootNode&quot;,
                new XAttribute(XNamespace.Xmlns + &quot;xsi&quot;, xsi.NamespaceName),
                new XAttribute(xsi + &quot;noNamespaceSchemaLocation&quot;, @&quot;..\path\to\schema.xsd&quot;));
</pre>
The above code will generate this:
<pre class="brush: xml;">&lt;rootNode xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;..\path\to\schema.xsd&quot; xmlns=&quot;http://www.foo.bar&quot; &gt;
&lt;/rootNode&gt;</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://www.somethingorothersoft.com/2010/01/28/adding-schemalocation-attribute-to-xelement-in-linq-to-sql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Apple Tablet &#8211; Make the pain stop</title>
		<link>http://www.somethingorothersoft.com/2010/01/18/apple-tablet-make-the-pain-stop/</link>
		<comments>http://www.somethingorothersoft.com/2010/01/18/apple-tablet-make-the-pain-stop/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 11:40:01 +0000</pubDate>
		<dc:creator>igor</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://www.somethingorothersoft.com/?p=205</guid>
		<description><![CDATA[Apple marketing machine has been working in overdrive by continually circulating tablet rumours. Everywhere you go (technology wise) you are bound to hear speculation on what the damn thing is. I can&#8217;t wait utill Jan 26 when they finally announce it so we can all be over it. This Week in Tech has a dedicated <a href="http://www.somethingorothersoft.com/2010/01/18/apple-tablet-make-the-pain-stop/" rel="bookmark" title="Read on...">[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Apple marketing machine has been working in overdrive by continually circulating tablet rumours. Everywhere you go (technology wise) you are bound to hear speculation on what the damn thing is. I can&#8217;t wait utill Jan 26 when they finally announce it so we can all be over it.</p>

<p>This Week in Tech has a dedicated half hour every show for the past two months about the iSlate and that&#8217;s getting a bit nauseating. I commend Valleywag for <a href="http://gawker.com/5448177/update-apple-wins-the-first-prize-in-our-tablet-scavenger-hunt">making light of the situation</a>.</p>

<p>Now that I offloaded my disgust at the hype around the device I can offer my 2c. The two things that make this a non-niche device are:</p>

<ul>
<li>Haptic display that will give you feedback when you touch it. This, IMHO, will make more-than-two-finger typing somewhat feasible.</li>
<li>A hybrid LCD/E-Ink display as suggested by <a href="http://techdirt.com/articles/20100114/1603307765.shtml">Techdirt</a>. Combining high-contrast and low battery consumption of E-Ink with versatility of LCD can make such hybrid an absulute killer.</li>
</ul>

<p>As far as I am concerned if the device is less groundbreaking than the above, it&#8217;ll flop. I think that in order for Apple to pull this off, the device has to be perceived as the technology of the future, even though the original product is ordinary.</p>

<p>I also think that the hardware itself has to be innovative. There has been a bit of a murmour that the success will depend on the content deals Apple makes for this device. I think that&#8217;s less relevant. The content availability hasn&#8217;t made the Apple TV successful and I think that because there wasn&#8217;t much innovation in the device. It&#8217;s almost as though the device needs to be able to play stuff that wasn&#8217;t bought through the store (read pirated) easily in order for it to be successful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.somethingorothersoft.com/2010/01/18/apple-tablet-make-the-pain-stop/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Thanks for the Chrissie present, iiNet</title>
		<link>http://www.somethingorothersoft.com/2009/12/26/thanks-for-the-chrissie-present-iinet/</link>
		<comments>http://www.somethingorothersoft.com/2009/12/26/thanks-for-the-chrissie-present-iinet/#comments</comments>
		<pubDate>Sat, 26 Dec 2009 08:10:04 +0000</pubDate>
		<dc:creator>igor</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[iinet]]></category>
		<category><![CDATA[teh-funny]]></category>

		<guid isPermaLink="false">http://www.somethingorothersoft.com/?p=176</guid>
		<description><![CDATA[Thanks for the quota-free day, guys, I certainly watched a lot of youtube :))]]></description>
			<content:encoded><![CDATA[<p>Thanks for the quota-free day, guys, I certainly watched a lot of youtube :))</p>

<p><a href="http://www.somethingorothersoft.com/wp-content/uploads/2009/12/volumegraphs.cgi_.png"><img src="http://www.somethingorothersoft.com/wp-content/uploads/2009/12/volumegraphs.cgi_.png" alt="volumegraphs.cgi" title="volumegraphs.cgi" width="640" height="400" class="alignnone size-full wp-image-177" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.somethingorothersoft.com/2009/12/26/thanks-for-the-chrissie-present-iinet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I believe in three douchebags</title>
		<link>http://www.somethingorothersoft.com/2009/12/16/i-believe-in-three-douchebags/</link>
		<comments>http://www.somethingorothersoft.com/2009/12/16/i-believe-in-three-douchebags/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 22:27:43 +0000</pubDate>
		<dc:creator>igor</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[downloading]]></category>
		<category><![CDATA[nocleanfeed]]></category>
		<category><![CDATA[openinternet]]></category>

		<guid isPermaLink="false">http://www.somethingorothersoft.com/?p=171</guid>
		<description><![CDATA[Every time our dear Senator Conroy makes an announcement it is met with much ridicule. It almost seems that he goes out of his way to seem as incompetent as possible. The whole internet filtering fiasco has been becoming more and more farcical over the past year. I wouldn&#8217;t have thought it could get more <a href="http://www.somethingorothersoft.com/2009/12/16/i-believe-in-three-douchebags/" rel="bookmark" title="Read on...">[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Every time our dear Senator Conroy makes an announcement it is met with much ridicule. It almost seems that he goes out of his way to seem as incompetent as possible. The whole internet filtering fiasco has been becoming more and more farcical over the past year. I wouldn&#8217;t have thought it could get more ridiculous but it it did.</p>

<p>Duncan Riley explains in detail how the whole study is flawed in great detail <a href="http://www.inquisitr.com/52298/australia-confirms-censorship-plans-tells-fibs-on-the-filtering-trial">here</a>. The government report has all the hallmarks of the justifications for going to war in Iraq. Especially the part where they say that the trial was a 100% success except for handling high traffic (especially video streaming) sites.</p>

<p>WTF???!!! I mean apart from those <a href="http://www.somethingorothersoft.com/2009/10/08/i-download-and-i-vote-oh-and-iitrial-is-cool/">evil evil pirates</a> who use bittorrent a lot of the traffic will be to youtube. And this brings me to the title  of the post &#8211; the three douchbags.</p>

<p>Due to how Testra <a href="http://exchange.telstra.com.au/2009/12/15/isp-blocking-our-evaluation-report/">set up their filter</a>, and I am using Telstra as an example here, if there is just one page on a site that is blocked, the whole site goes through a proxy. So it takes <strong>one</strong> douchebag to upload something potentially objectionable up on youtube, <strong>second</strong> douchebag to object to it and a <strong>third</strong> douchebag to place that page on a blocked list and to grind youtube to a halt for everyone.</p>

<p>Knowing the very vocal conservatives in this country the video in question will probably be some documentary about abortion with a half a second still shot of a bloody foetus which is perfectly fine by youtube standards and even by most broadcasting standards. Once the site is on a black list I seriously doubt an ISP can proxy all their youtube traffic through a single proxy. Not without spending quite a bit on their proxy farm anyway.</p>

<p>Imagine the outrage. All the school kids coming home will have to wait 10 minutes for the video of a dog driving a race kart. Guess what&#8217;s going to happen. They will go into very very slimy corners of the internets to find out how to circumvent the filter. God knows what else they are going to find there. Heck even the older people who <strong>can</strong> vote will not take too kindly to having their internet slowed down.</p>

<p>It&#8217;s not going to fly. I can just see wikileaks ending up on a blocked list, along with a thousand of &#8220;what&#8217;s blocked&#8221; sites set up by pundits that will pop up in the near future. It will be continual bad press for the government. I am going to vote for the <a href="http://www.pirateparty.org.au/">Pirate Party</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.somethingorothersoft.com/2009/12/16/i-believe-in-three-douchebags/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
