tag:blogger.com,1999:blog-151357002024-02-07T20:56:40.960+01:00throws dotNetExceptionPromoting common sense.
<br><br><i>Alternatively: Promoting uncommon sense and exposing common nonsense</i>Runehttp://www.blogger.com/profile/00640836124811415245noreply@blogger.comBlogger115125tag:blogger.com,1999:blog-15135700.post-15239887921104624372013-01-15T07:03:00.000+01:002013-01-15T10:23:01.609+01:00Amazon: Global selling done wrongI have an account at Amazon. Actually I have two. One at Amazon.com and one at Amazon.co.uk. In the beginning I just had one at Amazon.com, but to avoid import tax I had to create one in the EU as well. I don't really understand why I needs these two accounts.<br />
Apparantly Amazon only sells E-books through the american version, not the UK version. It's not that they won't sell them to me, they just require me to log into the american version to do the purchase.<br />
<br />
I once searched for the a kindle paperwhite, and now amazon is flodding my inbox with add campaigns for the kindle paperwhite. I can go through the order until i get to the shipping details. Why am I getting adds for stuff they won't sell me?<br />
Couldn't they just figure this out beforehand. I also find it strange that sales tax is not included in the listed prices. I know thats the way things work in the US but couldn't they change it for the rest of us.<br />
<br />
For the affiliate program it is just ridiculus. I have to link to a localized version of amazon. If my audience is global, there is no way to target everybody. I have to select what version of amazon I want to link to and miss out on all my users that can't use that version.<br />
<br />
Wouldn't it just be cool if they could use the information on my account to display the information that is relevant to me, or maybe just redirect me to the version of their site that is of use to me. Maybe I'm too demanding, but it would for sure make me a more happy customer.Runehttp://www.blogger.com/profile/00640836124811415245noreply@blogger.com0tag:blogger.com,1999:blog-15135700.post-40854472303178069322012-12-20T22:54:00.000+01:002012-12-20T22:55:16.200+01:00Fizz Buzz in APL<span style="font-family: inherit;">I came across the Fizz Fuzz programmers test and just couldn't help myself programming it in APL:</span><br />
<br />
p←0=3 5∘.|l←i←⍳100<br />
l[,p[1;]/i]←⊂'Fizz'<br />
l[,p[2;]/i]←⊂'Fuzz'<br />
l[(,∧⌿p)/i]←⊂'Fizz Buzz'<br />
<br />
And that is the way it is done (the code is self explanatory :))<br />
<br />
<br />
http://www.codinghorror.com/blog/2007/02/why-cant-programmers-program.htmlRunehttp://www.blogger.com/profile/00640836124811415245noreply@blogger.com0tag:blogger.com,1999:blog-15135700.post-38442779275061660482012-12-19T11:26:00.000+01:002012-12-19T13:55:06.636+01:00Software inovation by lawAt one point in time, some people figured out that the world was full of selfish bastards that would leech off each other and therefore smart people would not innovate because all their hard work would be stolen. The patent was invented and this allowed inventors to work on difficult problems and if succeeding be rewarded in the end. The leechers however have discovered that they can use the patent system for their own benefit. Instead of patenting stuff that represent a great effort they patent simple every day things like rectangles, colors or human gestures.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcm5U0F_usAvQo09wrHkI1AorvXctqqYo2clN3KFQAcyVuuKCMjOyjK0RM4vkOS22Vr5YFXa8LGLlCwvQ7TM3P7DJIXy0rvU35ZqfWRMlhCJ_Qunt-l9xIsEEGftkMI-5ebSDl/s1600/leech.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcm5U0F_usAvQo09wrHkI1AorvXctqqYo2clN3KFQAcyVuuKCMjOyjK0RM4vkOS22Vr5YFXa8LGLlCwvQ7TM3P7DJIXy0rvU35ZqfWRMlhCJ_Qunt-l9xIsEEGftkMI-5ebSDl/s1600/leech.jpg" /></a></div>
<br />
So now the patents are no longer used to defend the innovative from the bullies. Instead the bullies uses them to keep the innovative from being innovative. By having a vast amount of patents on everyday things and by keeping them to you self until someone has violated them, you effectively keep anyone from creating anything new unless they can afford a patent war against you.<br />
<br />
In other words, it no longer depends how good your ideas are but how much money you have. I hope someone with the power to be heard one day figures this out and requests the system to be changed. Patents should only cover things obtained through some kind of effort, and patent owners should be forced to license the use of their patents to others. Color combinations or shapes are not to be claimed by anyone as their property! That's just my opinion...Runehttp://www.blogger.com/profile/00640836124811415245noreply@blogger.com0tag:blogger.com,1999:blog-15135700.post-55107402530446532312012-12-18T05:30:00.000+01:002012-12-18T09:35:03.412+01:00Happy Happy Joy Joy.. Learning a new programming languageA year ago I started a new job. The company that is now my employer has a lot of code written in an old and obscure language called APL. So I have had to sit down and learn APL.<br />
<br />
APL is short for "A Programming Language" and being invented in 1953 it is a very old language. For me its a fresh new approach to programming. Instead of spawning from electronic engineers, APL comes from the twisted mind of a mathematician. That means that the language does not origin from abstracting processor instructions, but from what would be useful for doing math. This makes it an extremely high level language that is very powerful once you wrap you head around it. APL sees the world as vectors and matrixes (single dimensionned arrays and multi dimensioned arrays for the rest of us). Once you have your world defined in arrays, you will be amazed by the expressiveness that APL provides.<br />
<br />
I recently listened to hanselminutes where they talked about F#. One of the key points with F# was how little code you had to write to accomplish anything. The example given was <a href="http://en.wikipedia.org/wiki/Conway's_Game_of_Life" target="_blank">Conway's game of life</a>. Ruby could do it in 140 characters. F# weighed in with an impressive 127 characters. Compared to APL these languages are however very verbose. APL does the same thing in <strong>only 38 characters</strong>. To be fair, this problem is right down APL's alley as 'twodimensional array' is a native type of APL. <br />
<br />
<a href="http://tryapl.org/">http://tryapl.org/</a>
<br />
<br />
To begin with APL is completely unreadable. First of all, the character set used is not present in you favourite font. Secondly there is no operator prescedence in APL, Expressions are evaluated from right to left.<br />
<br />
<ul>
<li>3 + 4 = 7<br />returns 3 (4 is not equal to 7 and returns 0, 3 is added)</li>
<li>4 * 0 + 4<br />returns 16 </li>
<li>etc.</li>
</ul>
<div>
Example code from wikipedia:</div>
<div>
<pre style="background-color: #f9f9f9; border: 1px dashed rgb(47, 111, 171); font-family: monospace, Courier; font-size: 13px; line-height: 1.3em; padding: 1em;">(~R∊R∘.×R)/R←1↓⍳R</pre>
</div>
<br />
<br />
This code finds all the primenumbers up to R.Remember to read this from the right. <span style="background-color: #f9f9f9; font-family: monospace, Courier; font-size: 13px; line-height: 1.3em;">⍳R creates a vector containing the numbers from 1 to R. </span><span style="background-color: #f9f9f9; font-family: monospace, Courier; font-size: 13px; line-height: 1.3em;">1↓ drops the first element of that vector. The new vector is assigned to R. The / in this context means a filter, it will filter the vector on the right by the binary vector(elements are boolean). </span><br />
<span style="background-color: #f9f9f9; font-family: monospace, Courier; font-size: 13px; line-height: 1.3em;">R∘.×R</span><span style="background-color: #f9f9f9; font-family: monospace, Courier; font-size: 13px; line-height: 1.3em;"> produces a matrix(double sided array) containing the product of all combinations of numbers found in R. </span><span style="background-color: #f9f9f9; font-family: monospace, Courier; font-size: 13px; line-height: 1.3em;">R∊ produces a binary vector of all elements in R that are also on the right. The binary vector is inverted by </span><span style="background-color: #f9f9f9; font-family: monospace, Courier; font-size: 13px; line-height: 1.3em;">~ and the filter is applied. Voila, a vector of prime numbers.</span><br />
<br />
All in all it's great to learn a new language that is so different. This probably will never be language of choice but it has given me a different perspective on the other languages I use.Runehttp://www.blogger.com/profile/00640836124811415245noreply@blogger.com0tag:blogger.com,1999:blog-15135700.post-51146412899885021532012-08-09T07:48:00.000+02:002012-08-09T08:19:50.382+02:00Unit tests are not all black and whiteAnd they are not all red or green either. From a management perspective it might make sense to divide unit tests into the ones that pass, and mark everything else as an error. After all, this is what is confirmed to work and what is not.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkZMlJDFd6wO1MckRUGAxgzhYhph8lZlJulodw70jXSq6JcvFsWIFXWknm0X_lVtnhi1TShMud57ICBS_NyqrJMEhLEukqpPK0rEra6GJLsW1sP85S6tLIsdgk1Bms-_i4MxzY/s1600/greenred.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="74" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkZMlJDFd6wO1MckRUGAxgzhYhph8lZlJulodw70jXSq6JcvFsWIFXWknm0X_lVtnhi1TShMud57ICBS_NyqrJMEhLEukqpPK0rEra6GJLsW1sP85S6tLIsdgk1Bms-_i4MxzY/s320/greenred.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
From a development's perspective this approach makes less sense. The main goal is still to get all unit tests in the green zone. It's just that some of the test that do not pass are not errors that need immediate attention. Some of the error may already be planned to be fixed in the future, configuration problems or dependencies on resources that are not available at the moment of the test run.<br />
<br />
Take for example a test that uses a database (i known that technical it is not a unit test). You want to test that some updates are done correctly. If for some reason the database is down and you can't get an open connection to the database, would you fail the test? My suggestion is that you don't. The test is not about getting a connection to the database but about doing the update.<br />
<br />
<span style="background-color: white;">They way I like to use unit tests is to utilize the ignore or inconclusive state of tests. If it is some configuration, some 3. party component missing on the test machine or some error that is scheduled in the future I like to take them out of the errors in need of immediate attention.</span><br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhF_NQfuaegFW77SYkvYaAprIbmxgycxeCVDbTl-dcpR1z6YBoh08JDUKRb3pS1WxZ7dj8eTSAXVOutrCt_DpOJva26p5-h6s8aIxfmvheSv1QvboK0DIPh_voSyQIyFnyOF0AX/s1600/greenyellowred.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="88" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhF_NQfuaegFW77SYkvYaAprIbmxgycxeCVDbTl-dcpR1z6YBoh08JDUKRb3pS1WxZ7dj8eTSAXVOutrCt_DpOJva26p5-h6s8aIxfmvheSv1QvboK0DIPh_voSyQIyFnyOF0AX/s320/greenyellowred.png" width="320" /></a></div>
<br />
I have seen panicking because hundreds of tests fail just because the password of the database user had changed. This should maybe fail in a single test that verifies that the database is accessible, but not the whole test suite.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1M6q0Ik3p3O3tgobnIFjGCfaMluLFaOSxc1dipcNFZQbrQlnvwv2SSfJZXogas9jtYNVe0CSVyJLskZTEfLFyFG_0ZGbGIGtOU21FFH-9py6JghrJ9tNSKc_3dgZMEswTPA7a/s1600/greenyelloredperspective.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="213" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1M6q0Ik3p3O3tgobnIFjGCfaMluLFaOSxc1dipcNFZQbrQlnvwv2SSfJZXogas9jtYNVe0CSVyJLskZTEfLFyFG_0ZGbGIGtOU21FFH-9py6JghrJ9tNSKc_3dgZMEswTPA7a/s320/greenyelloredperspective.png" width="320" /></a></div>
<br />
It's a good idea to prioritize your tasks, and by using levels of severity in your unit tests you can optimize your bug fixing efforts a bit and focus on the errors that are real.Runehttp://www.blogger.com/profile/00640836124811415245noreply@blogger.com0tag:blogger.com,1999:blog-15135700.post-49103678035905404622012-08-07T17:30:00.000+02:002012-08-07T17:30:01.382+02:00Recursive lambdasMore and more programming languages supports a functional approach to programming. the functional approach gives a more compact syntax that for some people will be easier to read because everything can be kept together.<br />
<br />
In C#, lambda expressions take us closer towards functional programming. An important concept of functional programming is recursitivity which in many cases can replace loops.<br />
<br />
I pulled up my old <a href="http://dotnetexception.blogspot.com/2009/12/challenge-yourself.html" target="_blank">base conversion algoritm</a> and gave it a try. Basically it takes an integer and returns a string respresented in a base of your choice.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAE8XkluH7UaShqgKB6iw8g0Fqj6uCl2oGyKVFF5CreKBHfeK71IZFCPqMaHE2LlgltnzQnJG4LN2NYjeUQZ-b-tIYvhmcOTp5YQR2y3pEJPd0ekP2UVDrN_UYvFCNuIlNbfxT/s1600/baseformat.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="67" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAE8XkluH7UaShqgKB6iw8g0Fqj6uCl2oGyKVFF5CreKBHfeK71IZFCPqMaHE2LlgltnzQnJG4LN2NYjeUQZ-b-tIYvhmcOTp5YQR2y3pEJPd0ekP2UVDrN_UYvFCNuIlNbfxT/s640/baseformat.PNG" width="640" yda="true" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Integers to Text</td></tr>
</tbody></table>
<br />
The variable <span style="font-family: 'Courier New', Courier, monospace;"><i>chars</i> </span>contains the characters used in the output. For a conversion to base 16 (hex) the first 16 are used etc..<br />
C# doesn't let you reference something that is defined in the same line, so the signature of the lambda is defined in the previous line. The actual conversion is all written in one line of code and I'll let you decipher it yourselfes. Because of the recursion, no loop is required. It will basically calls itself for every character to be output. As C# doesn't support tail recursion (this is not completely true, but I won't count on it anyway), recursive code in C# has a limit to how many times a method can call itself.<br />
<br />
I also did one that goes the other way.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYAEZEJZCa2T5aRlomftIALg6ORwxG376T7ukFm9XRn4X7w0Wvs7n3Q2933Np5qixxKqyxrn-a0hFAv_N_30XJc0VZxcAE4NQvaq8VxjJMwugZ7V1YJ8uwj-w4MoYyZjZrtfPz/s1600/baseparse.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="27" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYAEZEJZCa2T5aRlomftIALg6ORwxG376T7ukFm9XRn4X7w0Wvs7n3Q2933Np5qixxKqyxrn-a0hFAv_N_30XJc0VZxcAE4NQvaq8VxjJMwugZ7V1YJ8uwj-w4MoYyZjZrtfPz/s640/baseparse.PNG" width="640" yda="true" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Text to Integer</td></tr>
</tbody></table>
What i have now is two methods so that I can convert from any base (limited to the length of the charset used) to any other base. this is how i convert a hex number into base 3.<br />
<br />
Console.WriteLine(format(parse("AF3D",16),3));<br />
<br />
<br />
<br />Runehttp://www.blogger.com/profile/00640836124811415245noreply@blogger.com0tag:blogger.com,1999:blog-15135700.post-13300116285285147462012-07-26T19:30:00.000+02:002012-07-26T19:30:01.293+02:00Inline, nested if statements<span style="font-family: inherit;">The <a href="http://msdn.microsoft.com/en-us/library/ty67wk28.aspx" target="_blank">?: operator</a> was something I had to get used to when I first saw it. I allows you to define a conditional if statement on a single line with a build in assignment. This compacts a lot of code and once you get used to it it's quite readable.</span><br />
<span style="font-family: inherit; font-size: x-small;"><br /></span><br />
<span style="color: blue; font-family: 'Courier New', Courier, monospace; font-size: x-small;">var <result> = <if-condition> ? <true value> : <false value>;</span><br />
<span style="font-family: inherit;"><br /></span><br />
<span style="background-color: white;"><span style="font-family: inherit;">This can, among other things, be used to translate values. In the following s will contain </span></span><span style="background-color: white;">the text "Small" if i is less than 3, otherwise "Not Small"</span><br />
<span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; font-size: x-small;"><br /></span><br />
<span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; font-size: x-small;">int? i = 4;</span><br />
<span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; font-size: x-small;">string s = i<3 ? "Small" : "Not small";</span><br />
<br />
Whatever is behind the colon, you can replace with a new inline if statement. Now its an if/else if/else statement on a single line.<br />
<br />
<span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; font-size: x-small;">string s = i<3 ? "Small" : i==3 ? "Three" : i>3 ? "Large" : "Not a Number";</span><br />
<br />
Which gives the same result as.<br />
<br />
<span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; font-size: x-small;">string s;</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><span style="color: blue; font-size: x-small;">if(i<3){</span></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><span style="color: blue; font-size: x-small;"> s = "Small";</span></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><span style="color: blue; font-size: x-small;">}else if(i==3){</span></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><span style="color: blue; font-size: x-small;"> s = "Three";</span></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><span style="color: blue; font-size: x-small;">}else if(i>3){</span></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><span style="color: blue; font-size: x-small;"> s = "Large";</span></span><br />
<span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; font-size: x-small;">}else{</span><br />
<span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; font-size: x-small;"> s = "Not a Number";</span><br />
<span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; font-size: x-small;">}</span><br />
<br />
This is even better when used in lambda expressions as a "standard" lambda expression only allows one statement.
<br />
<br />
<span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; font-size: x-small;">Console.WriteLine(</span><br />
<span style="color: blue;"><span style="font-family: 'Courier New', Courier, monospace;"><span style="font-size: x-small;"> </span></span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: x-small;">GetInts()</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: x-small;">.Select(i=>i<3?"Small":i==3?"Three":i>3?"Large":"Not a Number")</span></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><span style="color: blue; font-size: x-small;"> .Aggregate((x, y) => x + "\n" + y)</span></span><br />
<span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; font-size: x-small;">);</span>Runehttp://www.blogger.com/profile/00640836124811415245noreply@blogger.com0tag:blogger.com,1999:blog-15135700.post-37399065467762928292012-01-25T15:30:00.000+01:002012-01-28T23:46:38.450+01:00Era of the XAML user interfaceI hear the term <a href="http://msdn.microsoft.com/en-us/library/ms752059.aspx" target="_blank">XAML</a> user interfaces mentioned way too often these days.<br />
<br />
XAML has in fact nothing to do with userinterfaces. XAML is just a language for instantiating an object structure. I have previously written about how I have used it as a configuration language for my applications, a <a href="http://dotnetexception.blogspot.com/2008/04/xaml-ultra-lightweight-ioc-container.html" target="_blank">sort of light weight dependency injection framework</a>. To show that <a href="http://en.wikipedia.org/wiki/Windows_Presentation_Foundation" target="_blank">WPF</a> and <a href="http://en.wikipedia.org/wiki/Microsoft_Silverlight" target="_blank">Silverligth</a> are not the only UI frameworks that can be used with XAML I have used XAML to create a small <a href="http://en.wikipedia.org/wiki/Windows_Forms" target="_blank">Windows Forms</a> form.<br />
<br />
The root node of my XAML file will be Form. By providing "<span style="color: blue; font-family: Consolas;"><span style="color: blue; font-family: Consolas;"><span style="color: blue; font-family: Consolas;">clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms</span></span></span>" as the default namespace Visual Studio and .net will recognize the elements and validate them to match a structure that is allowed beneath a form. If you need to use other .net namespaces, you just add a prefixed xml namespace for each of those .net namespaces.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimX4rcLsgxf7yjFp47tYitNLRWrkZkSrpjRP1ZDczCnmc3iZXdwfAYVcUZo5heI6KUxCCf02nBIGN8eWnmhgwStAFHETHVZGnFVWzEZEXIshUQHxKklyTelr9O3L5LToi9uvQd/s1600/xamlform.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="230" nfa="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimX4rcLsgxf7yjFp47tYitNLRWrkZkSrpjRP1ZDczCnmc3iZXdwfAYVcUZo5heI6KUxCCf02nBIGN8eWnmhgwStAFHETHVZGnFVWzEZEXIshUQHxKklyTelr9O3L5LToi9uvQd/s400/xamlform.PNG" width="400" /></a></div>
<br />
<br />
Visual Studio will pr default open a WPF/Silverlight visual presentation along with the text editor when opening the XAML file. As we are not using WPF or silverlight the visual presentation will not show anything usefull. The XAML can be distributed as a file besides you application, embedded as XAML or embedded as BAML (XAML compiled to a binary format). The BAML approach is probably the most sensible solution for a real life application.<br />
<br />
To create an instance of the form just give the XAML stream to a XamlReader and cast the result to a Form object. Now the form can be displayed by calling Show, like you would on any other windows form.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzm1b3ummrm9H3qy4Ulh5qQCLT1m-vvN94H590aTE8ia5sTrBH6NeAbAF4pJ5FjjScLI0hD4WVeArG9UVvjsJzTOdX-Nerncj6G3eZwoCADj7l-u9ljgHTWVRgegZ0uZFYDSx4/s1600/hookupform.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="70" nfa="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzm1b3ummrm9H3qy4Ulh5qQCLT1m-vvN94H590aTE8ia5sTrBH6NeAbAF4pJ5FjjScLI0hD4WVeArG9UVvjsJzTOdX-Nerncj6G3eZwoCADj7l-u9ljgHTWVRgegZ0uZFYDSx4/s400/hookupform.PNG" width="400" /></a></div>
<br />
When the form object has been created, i use two lines of code to hookup some eventhandlers before showing the form. The find method on the form is an extension method for Form that flattens that flattens the structure of the form so that <a href="http://en.wikipedia.org/wiki/Language_Integrated_Query" target="_blank">LINQ</a> can be used on it. The generic type is a filter that only returns the controls of that type and the lambda is a further filter. The find method has been implemented in the plain framework, so you can go there to se the implementation.<br />
The Do method is just like the ForEach method on List, this however work for any type of IEnumerable<T>.<br />
<br />
The first of the two lines finds all buttons whose name start with "Command" and hook them up to an event handler. The second line hooks an event handler to the TextChanged event of all controls whose name start with Value. In this way it is easy to use a naming convention to hook the UI up to business logic. Dependind on your architecture, you might hook it up to fire commands or whatever.<br />
<br />
You might implement some layout manager the same way, or you might inherit panel or something other control and create a layout manager that way. By implementing you own controls you can also put metadata on the controls in your UI.<br />
<br />
So, XAML has the potential of being used with other UI frameworkds than WPF and Silverlight.<br />
<br />
<a href="http://dotnetexception.blogspot.com/2008/04/xaml-ultra-lightweight-ioc-container.html" target="_blank">http://dotnetexception.blogspot.com/2008/04/xaml-ultra-lightweight-ioc-container.html</a>Runehttp://www.blogger.com/profile/00640836124811415245noreply@blogger.com1tag:blogger.com,1999:blog-15135700.post-42534122910852309482012-01-19T15:29:00.000+01:002012-01-19T15:29:00.193+01:00Suitable Business model?I have created a prototype for an application.<br />
<ul>
<li>I know there is a market for what the application does as there are existing products that have same target audience.</li>
<li>Existing products are VERY pricy.</li>
<li>The product is simpler and easier to maintain than existing products in the market.</li>
</ul>
I just have one problem. How should I put this to market?<br />
<br />
<div>
A way could be to make it open source. This has worked for me with plain. Plain was however a theoretical experiment, a playground for thougths on how simple and easy application architecture could be made. There was never a plan for a final release because the process was more important. The no limits and no constraints meant that we could implement a search filter framework that resembled Linq a bit before we ever heard of Linq. A validation framework much like the one now found in nHibernate and ASP.Net Mvc 3 etc.. But plain intentionaly lacked one thing that I would like my new project to have. Exposure and usage.</div>
<ul>
<li>Open source the product and commercialize tools and support.</li>
<li>Open sourcing everything.</li>
<li>Make everything closed source.</li>
<li>Some others I haven't thought of.</li>
</ul>
<br />
<div>
</div>
This is a more finite problem and I want to work towards a releasable codebase. Will a enterprise product ever be popular if it is cheap?<br />
Will it be possible to have a differentiated licensing model for hobbyists and enterprises. Will this model result in a greater usage? Is it at all possible to have the kind of openness and transparency I'm looking for if the project is not open source?Runehttp://www.blogger.com/profile/00640836124811415245noreply@blogger.com0tag:blogger.com,1999:blog-15135700.post-28308893383340957842012-01-18T11:12:00.000+01:002012-01-18T11:12:01.330+01:00Declarative structure initializationI'm on the lookout for a <a href="http://martinfowler.com/articles/injection.html" target="_blank">Dependency Injection</a> framework for .net that supports a small, compact and declarative syntax. I want it to be so easy that non programmers can figure out what is going on.<br />
<br />
My first thoughts were on <a href="http://en.wikipedia.org/wiki/Extensible_Application_Markup_Language" target="_blank">XAML</a> as it is simple and declarative. The reason for not choosing this anyway is that it doesn't support generics in a nice way. By not in a nice way I mean very verbose and strange. On top of that XAML is not implemented on mono.<br />
<br />
<a href="http://www.springframework.net/" target="_blank">Springframework</a> and <a href="http://docs.castleproject.org/Windsor.MainPage.ashx" target="_blank">Castle Winsor</a> is also too verbose for my likings. Although they are very good, they still require me to define my object at one place and reference they together in a structure somewhere else. Thsi is not a bad thing, I would just, also, like the possibility to create the objects in the structure inline where they are needed.<br />
<br />
Another solution could be to consume code and execute it. This ofcorse is also way off compared to what I want to accomplish.<br />
<br />
Any Ideas on what path to follow?Runehttp://www.blogger.com/profile/00640836124811415245noreply@blogger.com0tag:blogger.com,1999:blog-15135700.post-68957010426832439782012-01-04T16:00:00.000+01:002012-01-17T10:45:40.657+01:00Wishlist: Derived generic parametersIn .Net generics gives a nice way to make type agnostic code that are not limited to a specific type.<br />
<br />
The following two types are taken from the plain framework.<br />
<br />
<span style="color: blue; font-family: "Courier New", Courier, monospace; font-size: x-small;">interface IBusinessEntity<T>{<br /> T Id {get;set;}<br />}</span><br />
<span style="font-family: "Courier New", Courier, monospace;"><br /></span><span style="color: blue; font-family: "Courier New", Courier, monospace; font-size: x-small;">interface IDao<T,TT> where T : IBusinessEntity<TT>{<br /> T Get(TT);<br /> TT Save(T);<br />}</span><br />
<br />
As shown you can use gemeric types as generic parameters for other types. In the IDao interface, I have specified that T must be a IBusinessEntity interface with the TT type as a generic parameter.<br />
In my example I will create a Article class that implements the IBusinessEntity interface and a generic Dao implementation<br />
<br />
<span style="color: blue; font-family: "Courier New", Courier, monospace; font-size: x-small;">class Article : IBusinessEntity<int>{<br /> //some code<br />}</span><br />
<span style="font-family: "Courier New", Courier, monospace;"><br /></span><span style="color: blue; font-family: "Courier New", Courier, monospace; font-size: x-small;">class Dao<T,TT> : IDao<T,TT>{<br /> //some code<br />}</span><br />
<span style="font-size: x-small;"><br /></span><br />
Now I want to get a dao for the class you just created. As Article has int as a generic parameter, the Dao objects has to defined with the article type as well as int to be able to compile.<br />
<br />
<span style="color: blue; font-family: "Courier New", Courier, monospace; font-size: x-small;">var dao = new Dao<Article,int>();</span><br />
<br />
Once you apply "Article", the only valid type as TT is "int". If you apply anything else, the compiler will let you know that "Article" is not valid. The reason for this is that in the definition of IDao, T has a requirement for T, not TT.<br />
It has been bugging me that the compiler complains about the type of T and not the type of TT. T is the important generic parameter, and TT could just be derived from that.<br />
<br />
In future releases of .net I would like to be able to write the following.<br />
<span style="color: blue; font-family: "Courier New", Courier, monospace; font-size: x-small;">interface IDao<T<TT>> where T : IBusinessEntity<TT>{</span><br />
<span style="color: blue; font-family: "Courier New", Courier, monospace; font-size: x-small;"> T Get(TT);<br /> TT Save(T);<br />}</span><br />
<span style="font-size: x-small;"><br /></span><br />
This way I could specify TT as part of the signature, but as TT is derived from what type T is, I would only have to specify T when using it.<br />
When creating the dao I could then write.<br />
<br />
<span style="color: blue; font-family: "Courier New", Courier, monospace; font-size: x-small;">var dao = new Dao<Article>();</span><br />
<br />
This is a small improvement, but it would remove some strange dependency error when using multiple generic parameters.Runehttp://www.blogger.com/profile/00640836124811415245noreply@blogger.com0tag:blogger.com,1999:blog-15135700.post-41739468590715901892011-11-10T13:45:00.004+01:002011-11-10T15:10:06.016+01:00Mostly immutableI have had the "pleasure" of working with BizTalk on a few projects now.<br />
<br />
I will save my general impression of Biztalk for another post. This is just to mention a undocumented side effect in BizTalk.<br />
<br />
One of the key things in BizTalk is that all messages are immutable. I have found this to be mostly true.<br />
<br />
In the following Message_1 and Message_2 are messages and should be immutable (except for in the block that constructs them)<br />
<br />
<span style="color: blue; font-family: 'Courier New', Courier, monospace; font-size: small;">Variable_1 = Message_1;<br />XmlSplitter.GetSFPage(Variable_1,0,2);<br />Message_2 = new System.Xml.XmlDocument();<br />Message_2.LoadXml(Message_1.OuterXml);</span><br />
<span style="color: lime; font-family: 'Courier New', Courier, monospace; font-size: small;"><br /></span><br />
Message_1 is constructed elsewhere and yet we are able to change it by loading it into an XmlDocument. the above code is XLANG and I think it's a bug that the first line of code does not clone the message.Runehttp://www.blogger.com/profile/00640836124811415245noreply@blogger.com2tag:blogger.com,1999:blog-15135700.post-24880185213727349902011-06-15T08:11:00.002+02:002011-06-16T09:51:40.049+02:00Token based credit cardsLike so many others I have an account on the playstation network. I also have accounts on iTunes and on Amazon. What these services have in common is that they save you credit card information on their servers so you don't have to type them every time you need to buy something from them.<div><br /></div><div>This makes it very easy for users to buy stuff from them once the users are logged into their systems. This design however has some serious flaws. A problem is that all the informations needed to withdraw money from your credit card is registered on each service provider. You have more or less handed out a master key to your bank account. Online trade is based on trust and although I do trust these sites not to misuse my creditcard details, they are just managed by humans and are therefore not perfect. </div><div><br /></div><div>What I would like to see is some kind of token based credit card for the internet. For any site that would like to persist my credit card information I could create a token that they could use to withdraw money from my credit card in the future. This way I could remove their access to my credit card without closing the card entirely. If the token was compromised I could see from which site they got it.</div><div>If the tokens included knowledge of the site it was to be used with, it would also be possible for banks to invalidate all tokens issued for a specific site such as Playstation Network.</div><div><br /></div><div>I just think the current creditcard technology on the net seems a bit outdated.</div>Runehttp://www.blogger.com/profile/00640836124811415245noreply@blogger.com1tag:blogger.com,1999:blog-15135700.post-87328145587840098502011-04-08T22:59:00.003+02:002011-04-08T23:09:57.354+02:00XPath - fixed!As you might have read in my previous post, I'm not too happy about the way the XPath works with namespaces.<div><br /></div><div>To make things better I have created some regular expressions that will allow me to write XPaths the way I want to write them and still have them work with real XPath engines out there. It makes the XPath ignorant towards namespaces that are not defined in my XPath query. Namespaces that are defined in my XPath query will be handled like before.</div><div><br /></div><div><div>if(!xpath.StartsWith("/")){</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>xpath= "./" + xpath;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>xpath = Regex.Replace(xpath,@"/(?<node>[\w]+)\[","/*[local-name()=='${node}' and ");<span class="Apple-tab-span" style="white-space:pre"> </span></node></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>xpath = Regex.Replace(xpath,@"/(?<node>[\w]+)","/*[local-name()=='${node}']");</node></div><div><br /></div></div><div>PS. I'll get back to the post and tidy the code up later</div>Runehttp://www.blogger.com/profile/00640836124811415245noreply@blogger.com3tag:blogger.com,1999:blog-15135700.post-73650162559592901842011-04-02T10:10:00.002+02:002011-04-06T15:52:22.350+02:00namespace mismatchOnce in a while you come across technologies that on their own are great, but put together are painful. Either you just live with the pain, you deselect one of the technologies or you try to improve the way they interact. This is the case with namespaces and xml/xpath.<div><br /></div><div>Let me just explain that I am a big fan of XML and of XPath and XMLSchemas. They are related and work quite nicely. The schemas describe the data structure and can be used for validation. The XML <b><i>is</i></b> the datastructure and XPath is the query language for searching in the datastructure. Together these are very powerful.</div><div><br /></div><div>Over the years I have heard a lot of people complain about XML, but often they are using it for the wrong purpose, they don't know the power of XPath to assist them or they are drowning in namespaces and prefixes in their xml documents.</div><div><br /></div><div>Namespaces in xml are introduced to allow cross references across schemas and thereby allowing reuse of schemas. Every namespace, other than the default namespace, is given a prefix. For loosely structured documents this enables the writer of the XML document to specify on every single element, in what namespace it is defined. A good example of that is the XSLT documents. Here prefixes helps the writer of the xml validate only the elements that are part of the XSLT transformation logic. For this purpose namespaces and prefixes are great.</div><div><br /></div><div>What I generally see with custom xml structures however is that the structure is more strictly defined and name clashes are less likely. </div><div><br /></div><div>If I were to define the way xml and xsd would work with namespaces I would make the namespace prefixes optional on xml nodes where type and namespace could be derived from its placement in the structure. If the schema eg. only allows for one type of "address" element at a given location, why should I specify what type of address element it is? Only where name and type clashes occur would I demand namespace prefixes.</div><div><br /></div><div>Namespaces should be treated as metadata of elements. They are just for validation and identifying the type of an element where name clashes could occur. For everything else they are irrelevant.</div><div><br /></div><div>That brings me on to XPath and namespaces. Namespace information is metadata as far as XPath is concerned and you have to ask for the details if you want to use it in the query. It's a different story with prefixes. Actually the prefix is part of the name you can search for. This makes absolutely no sense as prefixes are only valid within a single document, and a the next document you receive might have other prefixes but be just as valid. The impact is that you have to make your XPath queries quite verbose to ignore the prefix and it really is a painful experience. If I could redesign XPath, I would make XPath ignore the prefixes of elements to be the default behaviour. Actually I don't see where anyone should use the prefix knowledge in a search. </div><div><br /></div><div><br /></div>Runehttp://www.blogger.com/profile/00640836124811415245noreply@blogger.com0tag:blogger.com,1999:blog-15135700.post-65227846820462955332011-01-18T16:30:00.000+01:002011-01-19T09:01:02.326+01:00When descission makers are cluelessIt's a well known fact that you don't have to know anything to make a descision. Not knowing anything really speeds up the process of descisions and in some cases the descisions are just as good. In some cases they come with a price of being worthless or even disasterous.<br />
<br />
When you don't know about what you are to descide upon a common aproach is to seek advice by somebody that know something about the subject. <br />
<br />
Clueless descissions are most destructive when done in higher management because the consequences are often bigger. This includes politicians that are elected to make descissions. In Denmark there have rescently been some bad examples of such descissions regarding IT.<br />
<br />
<ol><li>Descissions about open document standards. Politicians kept OOXML in the loop although there was a better alternative that was more open at that time.</li>
<li>NemId was chosen as the new authentication for citizens of Denmark when communicating with the goverment. (about taxes and stuff). I have used it and its work nicely from the end users point of view. The problem with the solution is that is uses certificates with public/private keys... The private keys are placed on a centralized server. They have broken basic security principles and I think that is a problem.</li>
<li>Rejsekortet is a new way of paying for public transportation. To do this they implemented their own encryption algorithm. The system has not been put into production yet, but the encryption algoritm has already been broken.</li>
<li>Digital elections. Computers can be used for almost anything else. Elections part of a democratic proccess is not part of what computers can be used for. Pure electronic elections don't support recounting of votes and tampering with all votes can't be guarenteed. Elections of less importance, with truely trustworthy third parties can be implemented. Everybody has a interest in a democratic election and there is no trustworthy part that can ensure that the votes are not tampered with. It has been decided by politicians that electronic elections will be tried out.</li>
</ol>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-15135700.post-81360708393617103632011-01-18T10:03:00.002+01:002011-01-18T10:09:39.534+01:00Dynamic method bindingOne of the added features to C# 4.0 was dynamic objects. It gives late binding to C# so everything doesn't have to checked at compile time. In some cases this makes it a lot easier to use reflection as you don't have to use any of the .net API's to do so. You can act directly on the object as if you had the type at hand. All you need to know is the footprint of what you need to access. Most examples emphasize how this can be used when integrating with other technologies like old com objects etc, but I have been looking for usages outside that scope. One is ofcourse reflection, another one is dynamic method binding that I will try and explain.<br />
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: right; text-align: right;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbV9LwJc3RRlFnBgW6Gm78V_pG9IM-JPXydZGpmg8saPyXSkyEP2RBglH5s4ZX1DI8R1K30rRMprglew7iHKPbU4sAhilzhAg-ZykyG8JddxI2A0GAx5ZHVAHYScp1V0eH1JM/s1600/dynamicclasses.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" n4="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbV9LwJc3RRlFnBgW6Gm78V_pG9IM-JPXydZGpmg8saPyXSkyEP2RBglH5s4ZX1DI8R1K30rRMprglew7iHKPbU4sAhilzhAg-ZykyG8JddxI2A0GAx5ZHVAHYScp1V0eH1JM/s1600/dynamicclasses.PNG" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Basic OO with cats and dogs. <br />
<br />
<br />
<br />
</td></tr>
</tbody></table><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;">I create the traditionel object structure to support me explain what I mean. Animal is a pure abstract concept, Cat is an Animal and so is Dog.</div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"><br />
</div><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj16OB_zVDm7m7RQ3bl_6zpG7rsPreUekUO3_DDfj9Da-tLbFBh1PGbP3lp6fXnVM4l688tc6B16aB6CW8nMrpUwrLIwiG45MnrpYbBzhFntX7eXViSQdmH6NkKPbkcIs1z3kU/s1600/dynamicmethods.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" n4="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj16OB_zVDm7m7RQ3bl_6zpG7rsPreUekUO3_DDfj9Da-tLbFBh1PGbP3lp6fXnVM4l688tc6B16aB6CW8nMrpUwrLIwiG45MnrpYbBzhFntX7eXViSQdmH6NkKPbkcIs1z3kU/s1600/dynamicmethods.PNG" /></a></div></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Make the animals make som noise</td></tr>
</tbody></table>I have created a MakeSound method that operates on the interface and one for each of the classes. As there is no general sound that will match any animal I just print ????? to the screen when in the context of Animal. <br />
What I want is to have a list of animals containing cats and dogs and then call the MakeSound for each animal in the list.<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifjmqUnlpOZfz2yMfcopRg2SyYXFdhFyjnEY86IQYcdpJIhq8QY5U250RQ2Sy4rt2FWrTgLS-pfZDu4R1A9jmAz7cgROuTspyNC3HMDE5tyX49GDpe4gU8rgf6S-E7aE_Rp-M/s1600/dynamic.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" n4="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifjmqUnlpOZfz2yMfcopRg2SyYXFdhFyjnEY86IQYcdpJIhq8QY5U250RQ2Sy4rt2FWrTgLS-pfZDu4R1A9jmAz7cgROuTspyNC3HMDE5tyX49GDpe4gU8rgf6S-E7aE_Rp-M/s1600/dynamic.PNG" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">As in C# < 4.0</td></tr>
</tbody></table>The big question is what method is actually called. The answer is that the method binding is done at compile time, the best match is the method that takes the interface as a parameter. All the objects are treated as of type Animal. This is the way it has always worked in C# and it should therefore be no surprise if you have been in a similar situation. The output is as follows.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0hzkOctqx42XThzWSj9mMJX0zzPCWcdUv8F0Nw08PC656CdylrpEHwbIrOjpQobmqBjh7YXgXh5ltfAbb-CHFa_8xNb40nOWdOi_odiBNkEtQb6w-NEgOer9rJfSkWNWjRT8/s1600/outputVar.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" n4="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0hzkOctqx42XThzWSj9mMJX0zzPCWcdUv8F0Nw08PC656CdylrpEHwbIrOjpQobmqBjh7YXgXh5ltfAbb-CHFa_8xNb40nOWdOi_odiBNkEtQb6w-NEgOer9rJfSkWNWjRT8/s1600/outputVar.PNG" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Result of program with static method binding</td></tr>
</tbody></table> <br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="clear: right; cssfloat: right; float: right; margin-bottom: 1em; text-align: right;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfTlBeDbTHAWVhbczYT7zyFpzAWS7trjBVtxguJ6rTWhqsFALPCJNy6xSKVz_HA9ePZYCWB_bYKUGrHcxv5P9o72QRtbjE7HFuJ_1UHEjmbIJQP8fcERtNdBu0GwAjBLeVZgE/s1600/dynamicvar.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" n4="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfTlBeDbTHAWVhbczYT7zyFpzAWS7trjBVtxguJ6rTWhqsFALPCJNy6xSKVz_HA9ePZYCWB_bYKUGrHcxv5P9o72QRtbjE7HFuJ_1UHEjmbIJQP8fcERtNdBu0GwAjBLeVZgE/s1600/dynamicvar.PNG" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Use of var keyword</td></tr>
</tbody></table> <br />
<div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;">With C# 3.5 the var keyword was introduced. One might think that this changed the way this would work as the programmer no longer defines the type and the framework should therefore be able to select a better method implementation automatically. The answer is that the var is just a way to have the compiler derive the type instead of the programmer. This is all done at compile time and the best match will therefore still be the method that operates on the interface.</div><br />
<div class="separator" style="clear: both; text-align: center;"></div><table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxwsAxz7NlEcM9pl06cY8dh_22k7CrPhUwlvIv5cifYhBw8lCpmng7R4saXmZdERzBEf9X33oix364eiFcIGSI2BPEqZ5ULtvehYnkW_3xI97Urm3O_GSglN1JY963pnk0mjY/s1600/dynamicchange.PNG" imageanchor="1" style="clear: left; cssfloat: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" n4="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxwsAxz7NlEcM9pl06cY8dh_22k7CrPhUwlvIv5cifYhBw8lCpmng7R4saXmZdERzBEf9X33oix364eiFcIGSI2BPEqZ5ULtvehYnkW_3xI97Urm3O_GSglN1JY963pnk0mjY/s1600/dynamicchange.PNG" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Handle the objects as dynamic instead</td></tr>
</tbody></table><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;">The dynamic keyword was introduced with C# 4.0 and this changes the possibilities when writing code like this. When treating every object in the list as a dynamic object, the compiler won't bind to any method but will leave it to the runtime to make the connection. This means that the type of every object is considered and handled on its own and the items in the list won't nescesarily result in the same method being called. This can be very usefull when iterating tree structures etc. The downside is that you will have no intellisense and no compile time validation when writing the code.</div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"><br />
</div>As the best methods are now called, the output will be cat and dog specific.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_xSGEmZ4gVDgO2ak4iS5VB779mLerswbAwv8VRZZkWapzvzi9iqjkeDlOzrSa6Nv3-a4oaI2S0VA2FFVqcSEAleqfOxAsAf3pWRIHeHOSY3JihVG2vzYG9MKaRkkpeVyn_wE/s1600/outputdynamic.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" n4="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_xSGEmZ4gVDgO2ak4iS5VB779mLerswbAwv8VRZZkWapzvzi9iqjkeDlOzrSa6Nv3-a4oaI2S0VA2FFVqcSEAleqfOxAsAf3pWRIHeHOSY3JihVG2vzYG9MKaRkkpeVyn_wE/s1600/outputdynamic.PNG" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Output when treating the objects as dynamic</td></tr>
</tbody></table>This can definately clean up some of my code. I might write a comment along with the code so that people in the future can figure out my intentions.<br />
<br />
Related posts:<br />
<a href="http://dotnetexception.blogspot.com/2009/11/wrapping-objects-with-interfaces.html">Wrapping objects with interfaces</a><br />
<a href="http://dotnetexception.blogspot.com/2009/11/dynamic-duck-typing-in-net-35.html">Dynamic duck typing in .Net 3.5</a>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-15135700.post-67592485093234965732010-09-13T03:44:00.002+02:002010-09-13T04:24:57.724+02:00Testers vs. DevelopersSome time ago I read somewhere that Microsoft had problems getting software testers in Denmark. They were puzzled by this as they found the workforce to be educated and they had no trouble finding developers.<br />
<br />
<br />
Although testers and developers should share some common knowledge of technology, their personalities are completely different. Good developers need to be inovative to be able to find solutions to problem they have never seen before. They should focus on the big picture and always strive for the best compromise. Good testers on the other hand have to focus on details and they need to be able to repeat an exact action and follow a script. The qualities wanted are opposites and it will most likely never be possible to find a person that posseses both.<br />
<br />
Links:<br />
<br />
<ul><li><a href="http://dotnetexception.blogspot.com/2007/11/my-prefered-developer-profile.html">My Prefered Developer Profile</a></li>
<li><a href="http://dotnetexception.blogspot.com/2010/01/there-is-no-such-thing-as-perfect.html">There is no such thing as perfect</a></li>
</ul><br />
<br />
<a href="http://www.version2.dk/artikel/14884-test-er-fy-ord-i-jobannoncer-microsoft-kan-ikke-hyre-danske-software-testere">http://www.version2.dk/artikel/14884-test-er-fy-ord-i-jobannoncer-microsoft-kan-ikke-hyre-danske-software-testere</a>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-15135700.post-4866487290043222232010-08-06T11:24:00.000+02:002010-08-06T11:24:08.920+02:005 years and still goingYesterday it was 5 years since I started this blog. I started it because I needed somewhere to let steam out. (And I actually started it together with a friend) I wasn't sure I would be able to continue posting to it but after 5 years I still have issues I want to share (with myself). Luckily the world never stops changing and I never stop discovering things I hadn't thought of before.<br />
<br />
The focus has been from very technical to philosofical about human nature. I'm looking forward for all the new blogpost that I am to write :)Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-15135700.post-45212256624135795842010-06-23T17:25:00.002+02:002010-06-23T17:25:00.482+02:00Trust me, I know what I'm doingTrust is important to any social relationship or communication. While I was out for a run I listened to a podcast about this and it really made me think. It stated that trust is also good for business. If you trust your surroundings you will be more open for doing business. Societies based on trust have a higher growth than societies that do not incorporate trust. This is a great message that I will try to spread around.<br />
<br />
On a personal level you will gain a lot by trusting other people as well. By doing so you can benefit a lot more from other people. If you for instance are an employer, but don't trust your employees the only value they can add to your organisation is doing the stuff you though of to begin with. Once you trust your employees, they will be able to add value to your organisation on their own. You will no longer have to supervise them and they will be able to inovate. They will have to take ownership and it will lead to a higher level of motivation.<br />
<br />
Actually you should not trust me because I know what I am doing. You should trust me because it is in my best interrest to help you out and because you will benefit more if you let me do it my way.<br />
<br />
Related posts:<br />
<a href="http://dotnetexception.blogspot.com/2010/04/leadership-is-about-motivation.html">http://dotnetexception.blogspot.com/2010/04/leadership-is-about-motivation.html</a><br />
<a href="http://dotnetexception.blogspot.com/2009/11/flank-your-problems.html">http://dotnetexception.blogspot.com/2009/11/flank-your-problems.html</a><br />
<a href="http://dotnetexception.blogspot.com/2010/01/there-is-no-such-thing-as-perfect.html">http://dotnetexception.blogspot.com/2010/01/there-is-no-such-thing-as-perfect.html</a><br />
<a href="http://dotnetexception.blogspot.com/2009/03/misunderstanding-path-to-new-ideas.html">http://dotnetexception.blogspot.com/2009/03/misunderstanding-path-to-new-ideas.html</a>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-15135700.post-29111881351546467082010-05-14T16:26:00.000+02:002010-05-12T11:41:33.465+02:00Discuss this!I have categorized discussions in 4 groups<br />
<br />
<strong>Religious</strong><br />
When in the context of a religion, the main goal of a discussion is to reach an already given conclusion. Any valid arguments are discharted if they contradict the given conclusion.<br />
This kind of discussion is often held by religious people such as evangelists (the software kind too) or sales people. It's also the favorite form for drunk people trying to argue that they are not drunk.<br />
Religious discussions also occur if you are too specialized. If the only tool you know how to use is a hammer, you are bound to use a hammer to solve every problem.<br />
<br />
<strong>Philosophical</strong><br />
These are discussions without a goal. That might sound useless, but it's not that bad at all. It's about questioning your own beliefs.<br />
It's a mind opener. It's about challenging your ideas, getting the big picture.<br />
<br />
<strong>Scientific</strong><br />
The scientific discussion is about reducing the complexity of a domain. The conclusions might be inaccurate, but it should result in the optimal solution all things considered. Issues like feasibility and return of investment are handled in these discussions as well as risks. It should be noted that a conclusion concluded today, might me changed tomorrow. Scientific discussions embrace and accept change.<br />
<br />
<strong>Lawful</strong><br />
Law is about details. The more the merrier. When you reach the maximum amount of details any human can comprehend, you are about half way there. The downside is that often the big picture and reasoning is lost in the pursuit for details. Although the focus is on details, even the details are sometimes lost in discussions like that. The last man standing is the one with photographic memory and who can stay awake the longest. To succeed in this category I suggest that you give up on any social life and start nit picking on your surroundings. Although there can be a winner in such a discussion, the real looser is the common sense and productivity.<br />
Law is a primal discussion form and we are trained to master it when we have arguments in kindergarten about what is right and wrong and which kid has more candy (milimeterdemokrati).<br />
<br />
<br />
When it comes to software development, you might have these different discussions at different points of time on your project. The religious discussions occur in the beginning of a project, or when changes to the project occur. Although the religious debate has a high return in the short term, the long term might suffer.<br />
As the philosophical discussion is about challenging your current beliefs, it's great for workshops or when a project is stuck in a dead end.<br />
The scientific discussion is great for decision making on a project. What separates a decision derived from a scientific discussion from a religious discussion is the scope.<br />
The lawful discussion comes into play on a software project when someone feels he's not treated right. The discussion often can't be resolved by the parties involved and a third party is then required.<br />
<br />
Let the discussions begin!Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-15135700.post-16105260891584949492010-04-13T09:18:00.003+02:002010-04-13T09:38:29.818+02:00Change the world, bit by bitAlthough you meet resistance, you should still still keep on trying to change the world.<br />
<br />
When it comes to software you are often met with statements like:<br />
<br />
<ul><li>This technology is going to be a mayor player.</li>
<li>Its a strategic decission to use this product.</li>
<li>Thats what the client wants.</li>
</ul><br />
<br />
If you are a software developer and know better than what has been presented to you, you should share this knowledge. If we let the world evolve by the words of marketing people, complexity will keep on increasing, with out any innovation. If you want to help reducing complexity, please do let the people around you know when they are mistaken.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-15135700.post-65004391788491357612010-04-12T07:01:00.002+02:002010-04-12T08:52:21.409+02:00Hierarchy of Information<div>Most enterprise software solutions deals with data. Actually I can't think of any that don't. Many enterprise solutions deal with lots of data. The application helps the user to deal with these massive amounts of data.<br />
<div><br />
I think of different levels of information. Each level decreases in size, but increases in value. Data in its lowest level is not very valuable. A bit or a byte of data is quite useless out of context. When characters are added together to form a string, the value increases significantly. A string in the form of a sentence is easier to remember than a equally amount of random bytes. The amount of information has decreased, but its value has increased. We are now able to compress the information to something smaller. Raw data is refined to information, knowledge and wisdom.<br />
<br />
<br />
<br />
<img alt="" border="0" id="BLOGGER_PHOTO_ID_5089201369850016466" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjO2J3zJPunTQZ0TpPf89ujRTnezBLJyYOgZacIa0xLanEdJnyiFV9p1EPN-LD3s3n4dp6uz3r4Z02HHoaScrvoQtPuc8txj2X2l6NnAUwG-kHvqCQnPNqFfgReYcOXW1iupzU/s400/datapyramid.png" style="cursor: hand; display: block; margin: 0px auto 10px; text-align: center;" /><br />
<br />
<br />
<br />
<br />
The Earth computer in <a href="http://www.amazon.co.uk/gp/product/0330258648?ie=UTF8&tag=throwsdotnete-21&linkCode=as2&camp=1634&creative=19450&creativeASIN=0330258648">The Hitchhiker's Guide To The Galaxy</a><img alt="" border="0" height="1" src="http://www.assoc-amazon.co.uk/e/ir?t=throwsdotnete-21&l=as2&o=2&a=0330258648" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; margin: 0px;" width="1" /> is the ultimate example of this refinement of information. All the information in the world is refined to the very short and easy to remember result: <em>"42".</em> If this was not fiction, this result would be the single most valuable piece of information.<br />
<br />
<br />
Every business strives to find the secrets of making lots of money( or save the planet ), and every business application is build to expose these secrets. </div></div>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-15135700.post-34403327310159569102010-04-07T18:04:00.005+02:002010-04-07T19:50:50.484+02:00Somebody has been reading my mindThis december I won a book (actually I won four, but the other ones were just not as great) in a technology contest. I don't know how I have missed out on this one. I have seen it on the booksshelfes but I have not read it until now. I must say that its brilliant. "The Pragmatic Programmer" is a pleasure to read.<br />
<br />
<br />
<a href="http://www.amazon.co.uk/gp/product/020161622X?ie=UTF8&tag=throwsdotnete-21&linkCode=as2&camp=1634&creative=6738&creativeASIN=020161622X" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://ecx.images-amazon.com/images/I/41HXiIojloL._SL160_.jpg" /></a>The Pragmatic programmer is about thinking while you develop. It promotes the obvious that is apparently not as obvious as we thought. Its as if the authors read my blog posts before I even wrote them :) This book really makes you think and I hope I can get my current collegues as well as future ones to read this so they can reflect a little about their actions.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-15135700.post-31201899137750537002010-04-06T16:26:00.003+02:002010-05-20T21:25:59.473+02:00Leadership is about motivationLeadership is not a simple task, but I think you will come far if you focus on motivation.<br />
<br />
How to motivate while you lead can be done in a number of ways. The first step is of course to understand your teammembers. Find out what makes them tick.<br />
I think the best way to go is to find common interests and focus on that. Knowing the persons on your team makes it easier to find something that will naturally interest the individual.<br />
<br />
<span style="font-size: large;">Cool cash</span><br />
This an easy way to motivate people. Money is a fundamental requirement for everybody. The problem with this is thats if this is your only motivator you can easily be outbid by others.<br />
If we reflect this to training a dog this resemples giving your dog treats when it does what you tell it to. It will work as long as the dog is hungry and likes your treats. If someone shows up with better treats you have lost.<br />
<br />
<span style="font-size: large;">Fear</span><br />
This is the opposite of the Cool Cash motivator. This is where you punish people if they don't do as they are told. This method has worked like a charm for many dictators in the past. The downside is that there can't be any alternatives to your leadership, and thats not easy to enforce in todays society. This works best if you have an uneducated workforce.<br />
In dog training this resembles beating your dog untill it does it right.<br />
<br />
<span style="font-size: large;">Common interests</span><br />
You need emphathy to succed with this one. You need to understand what drives the people working for you. If your workforce matches the tasks you have, it's going to be easy. They will more or less do it right whatever you say. This is about choosing the right team for the job. If you need to herd sheep, choosing a hunting dog would be a bad choice.<br />
<br />
Once you have your team put together you need to know what drives your team members. Some people strive for acknowledgement by coworkers, some live by the shear technology challenge presented to them and other people strive by other things. It's important to realize that motivation is not just important as to maximize output by your team. If you don't know how to motivate your team, it will collapse. And chances are that it will influence other parts of your business.<br />
In dog world this resembles: If you have a herd dog and don't provide stimuli, it will take your house apart.Unknownnoreply@blogger.com0