<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0"><id>tag:blogger.com,1999:blog-6349904622030791405</id><updated>2012-03-21T11:51:26.409Z</updated><category term="Bug" /><category term="Interfaces" /><category term="article" /><category term="Rant" /><category term="Stacked" /><category term="Programming" /><category term="Interviews" /><title type="text">Frozzn Software</title><subtitle type="html">Strong opinions held loosely</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://blog.frozzn.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://blog.frozzn.com/" /><author><name>cgreeno</name><uri>http://www.blogger.com/profile/18114822473402093049</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/FrozznSoftware" /><feedburner:info uri="frozznsoftware" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:browserFriendly></feedburner:browserFriendly><entry><id>tag:blogger.com,1999:blog-6349904622030791405.post-3021561734216131151</id><published>2010-06-24T00:39:00.004+01:00</published><updated>2011-02-02T22:26:37.916Z</updated><category scheme="http://www.blogger.com/atom/ns#" term="Interfaces" /><title type="text">Understanding IEquatable</title><content type="html">Since Generics came along in C# 2.0 we have had a new interface to allow for type safe comparisons. That Interface is &lt;a href="http://msdn.microsoft.com/en-us/library/ms131187.aspx"&gt;IEquatable&lt;/a&gt; which is a vast improvemnet over the previous &lt;a href="http://msdn.microsoft.com/en-us/library/system.object.equals.aspx"&gt;Equals &lt;/a&gt;that was hung off object in the BCL. &lt;br /&gt;&lt;br /&gt;MSDN Says:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;The IEquatable&lt;t&gt; interface is used by generic collection objects such as Dictionary&lt;TKey, TValue&gt;, List&lt;t&gt;, and LinkedList&lt;t&gt; when testing for equality in such methods as Contains, IndexOf, LastIndexOf, and Remove. It should be implemented for any object that might be stored in a generic collection.&lt;br /&gt;&lt;br /&gt;If you implement IEquatable&lt;t&gt;, you should also override the base class implementations of Object.Equals(Object) and GetHashCode so that their behavior is consistent with that of the IEquatable&lt;t&gt;.Equals method. If you do override Object.Equals(Object), your overridden implementation is also called in calls to the static Equals(System.Object, System.Object) method on your class. This ensures that all invocations of the Equals method return consistent results.&lt;/blockquote&gt;&lt;br /&gt;So how would I use IEquatable? I always liked using code to demonstrate.&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;public class IEquatableOverride&lt;br /&gt;{&lt;br /&gt;    private static Dictionary&amp;lt;Person,Person&amp;gt; ObjectDic = new Dictionary&amp;lt;Person,Person&amp;gt;();&lt;br /&gt;    private static Dictionary&amp;lt;int, Person&amp;gt; IntDic = new Dictionary&amp;lt;int, Person&amp;gt;();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        public static void  LoadDictionary()&lt;br /&gt;        {&lt;br /&gt;            Person p = new Person();&lt;br /&gt;            p.PersonId = 101;&lt;br /&gt;            p.First = &amp;quot;John&amp;quot;;&lt;br /&gt;            p.Last = &amp;quot;Doe&amp;quot;;&lt;br /&gt;            p.Age = 30;&lt;br /&gt;            p.Address = &amp;quot;My Address&amp;quot;;&lt;br /&gt;&lt;br /&gt;            ObjectDic.Add(p, p);&lt;br /&gt;            IntDic.Add(p.PersonId, p);&lt;br /&gt;&lt;br /&gt;            Console.WriteLine(&amp;quot; Can Find Object &amp;quot;+ObjectDic.ContainsKey(p));&lt;br /&gt;            Console.WriteLine(&amp;quot; Can Find by Key &amp;quot; + IntDic.ContainsKey(p.PersonId));&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            Person p2 = new Person();&lt;br /&gt;            p2.PersonId = 101;&lt;br /&gt;            p2.First = &amp;quot;John&amp;quot;;&lt;br /&gt;            p2.Last = &amp;quot;Doe&amp;quot;;&lt;br /&gt;            p2.Age = 30;&lt;br /&gt;            p2.Address = &amp;quot;test&amp;quot;;&lt;br /&gt;&lt;br /&gt;            ///R1&lt;br /&gt;            Console.WriteLine(&amp;quot; Can Find Object &amp;quot; + ObjectDic.ContainsKey(p2));&lt;br /&gt;            Console.WriteLine(&amp;quot; Can Find by Key &amp;quot; + IntDic.ContainsKey(p2.PersonId));&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public class Person : IEquatable&amp;lt;Person&amp;gt;&lt;br /&gt;    {&lt;br /&gt;        public int PersonId { get; set; }&lt;br /&gt;        public string First { get; set; }&lt;br /&gt;        public string Last { get; set; }&lt;br /&gt;        public int Age { get; set; }&lt;br /&gt;        public string Address { get; set; }&lt;br /&gt;&lt;br /&gt;        //Commenting this out result in #R1 being false&lt;br /&gt;        public override int GetHashCode()&lt;br /&gt;        {&lt;br /&gt;            ///In propper use this should be immutable&lt;br /&gt;            return First.GetHashCode() ^ Last.GetHashCode() ^ Age.GetHashCode();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public bool Equals(Person person)&lt;br /&gt;        {&lt;br /&gt;            if(person == this)&lt;br /&gt;                return true;&lt;br /&gt;            if(person.First == this.First &amp;amp;&amp;amp; &lt;br /&gt;               person.Last == this.Last &amp;amp;&amp;amp; &lt;br /&gt;               person.Age == this.Age)&lt;br /&gt;                    return true;&lt;br /&gt;&lt;br /&gt;            return false;&lt;br /&gt;        } &lt;br /&gt;  }&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;So as you can see above if we don't override GetHash then when compareing values in a Dictionary we would get erroneous results. This seems to work but why would I override GetHash if I wasn't using the object as the key and why do I need to override Object.Equals I thought that was the whole point of having Generics? &lt;br /&gt;&lt;br /&gt;Yes that is the point of generics but there was life before generics one example would be an ArrayList. Anybody remember those bad boys? Well if we create a new ArrayList and add p to it  and then compare it to p2 like so:&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;arrayList.Add(p);&lt;br /&gt;Console.WriteLine(&amp;quot;Can Find in ArrayList &amp;quot; + arrayList.Contains(p2));&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Can anybody guess what the output of the above line will be? Yep you guessed it False. It is still using the old Object.Equals if we add this to our person class everything turns peachy.&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;&lt;br /&gt;public override bool Equals(object obj)&lt;br /&gt;        {&lt;br /&gt;            Person person = obj as Person;&lt;br /&gt;            if (person == this)&lt;br /&gt;                return true;&lt;br /&gt;            if (person == null)&lt;br /&gt;                return false;&lt;br /&gt;&lt;br /&gt;            if (person.First == this.First &amp;amp;&amp;amp;&lt;br /&gt;               person.Last == this.Last &amp;amp;&amp;amp;&lt;br /&gt;               person.Age == this.Age)&lt;br /&gt;                return true;&lt;br /&gt;&lt;br /&gt;            return false;&lt;br /&gt;        }&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;OK but what if we just use generic lists that implement IEquatable so I don't to worry about Object.Equals and I am using a primary key for my Dictionary key. So I am not going to bother with Overridding GetHashCode either.&lt;br /&gt;&lt;br /&gt;Nope wrong again, LinQ is also a friend to GetHashCode so even though I am currently not using LinQ functionality in my results if I ever chose to do so and used a method like Distinct or Group By I would not get the results I would expect. So in short even though we have our brand new fancy interface we need to be careful how we use it.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Further Reading:&lt;br /&gt;&lt;br /&gt;From &lt;a href="http://blogs.msdn.com/b/jaredpar/archive/2009/01/15/if-you-implement-iequatable-t-you-still-must-override-object-s-equals-and-gethashcode.aspx"&gt;Jaredpar&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://codebetter.com/blogs/david.hayden/archive/2005/02/22/51364.aspx"&gt;CodeBetter&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6349904622030791405-3021561734216131151?l=blog.frozzn.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.frozzn.com/feeds/3021561734216131151/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.frozzn.com/2010/06/understanding-iequatable.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/3021561734216131151" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/3021561734216131151" /><link rel="alternate" type="text/html" href="http://blog.frozzn.com/2010/06/understanding-iequatable.html" title="Understanding IEquatable" /><author><name>cgreeno</name><uri>http://www.blogger.com/profile/18114822473402093049</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6349904622030791405.post-620900364192980537</id><published>2010-03-20T02:01:00.005Z</published><updated>2010-05-27T16:35:30.822+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Bug" /><title type="text">NHibernate.ByteCode.Castle.ProxyFactoryFactory</title><content type="html">Anyone seen this error message?&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;Unable to load type 'NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle'&lt;br /&gt; during configuration of proxy factory class. &lt;br /&gt;Possible causes are: &lt;br /&gt;- The NHibernate.Bytecode provider assembly was not deployed. &lt;br /&gt;- The typeName used to initialize the 'proxyfactory.factory_class' &lt;br /&gt;property of the session-factory section is not well formed.&lt;br /&gt;&lt;br /&gt;Solution: &lt;br /&gt;Confirm that your deployment folder contains one of the following assemblies: &lt;br /&gt;NHibernate.ByteCode.LinFu.dll &lt;br /&gt;NHibernate.ByteCode.Castle.dll&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Well after hours of searching I finally found that if I changed my target build from x86 to x64 the problem resolves itself. This has to go into my top 10 most annoying bugs of all time.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6349904622030791405-620900364192980537?l=blog.frozzn.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.frozzn.com/feeds/620900364192980537/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.frozzn.com/2010/03/nhibernatebytecodecastleproxyfactoryfac.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/620900364192980537" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/620900364192980537" /><link rel="alternate" type="text/html" href="http://blog.frozzn.com/2010/03/nhibernatebytecodecastleproxyfactoryfac.html" title="NHibernate.ByteCode.Castle.ProxyFactoryFactory" /><author><name>cgreeno</name><uri>http://www.blogger.com/profile/18114822473402093049</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6349904622030791405.post-2818279091049447630</id><published>2010-03-07T18:32:00.006Z</published><updated>2010-03-08T23:36:28.984Z</updated><category scheme="http://www.blogger.com/atom/ns#" term="Interviews" /><title type="text">Better then FizzBuzz</title><content type="html">Anyone that has done a few interviews has come to conclusion that a lot of people that apply for programming jobs &lt;a href="http://www.codinghorror.com/blog/2007/02/why-cant-programmers-program.html"&gt;cant program.&lt;/a&gt; In response to this usually the first question given to new applicants is a simple programming question like &lt;a href="http://www.codinghorror.com/blog/2007/02/fizzbuzz-the-programmers-stairway-to-heaven.html"&gt;fizzbuzz.&lt;/a&gt; FizzBuzz is an interesting problem but there is a lot of other problems out there that are just as simple and can provide much more information. &lt;br /&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Collatz_conjecture"&gt;&lt;b&gt;Collatz conjecture&lt;/b&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Take any natural number n (excluding 0). If n is even, halve it (n / 2), otherwise multiply it by 3 and add 1 to obtain 3n + 1. The conjecture is that for all numbers this process converges to 1. It has been called "Half Or Triple Plus One", sometimes called HOTPO.&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;&lt;br /&gt;public static void Calculate(Int64 val)&lt;br /&gt;{&lt;br /&gt;    if (val &amp;gt; 1)&lt;br /&gt;        if (val % 2 == 0)&lt;br /&gt;            Calculate(val / 2);&lt;br /&gt;        else&lt;br /&gt;            Calculate(val*3 + 1);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public static void CalculateCollatz2(Int64 val)&lt;br /&gt;{&lt;br /&gt;   while(val != 1)&lt;br /&gt;   {&lt;br /&gt;       if (val % 2 == 0)&lt;br /&gt;           val = val / 2;&lt;br /&gt;       else&lt;br /&gt;           val = val*3 + 1;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;This is one of my favourite tests, any programmer should be able to see in seconds that the very nature of this problem lends itself to a recursive solution. They &lt;i&gt;should&lt;/i&gt; also see the obvious stackoverflow that is possible. Either solving this recursively(Calculate) or with an iterator(Calculate2) allows you to dig a little further into the candidates programming knowledge. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Reversing a String&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Given a string reverse the output&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;&lt;br /&gt;public static string Reverse(string inValue)&lt;br /&gt;{&lt;br /&gt;    StringBuilder sb = new StringBuilder();&lt;br /&gt;    foreach (char c in inValue.Reverse())&lt;br /&gt;        sb.Append(c);  &lt;br /&gt;    &lt;br /&gt;    return sb.ToString();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public static string Reverse2(string inValue)&lt;br /&gt;{&lt;br /&gt;    int length = inValue.Length;&lt;br /&gt;    char[] charArray = new char[length];&lt;br /&gt;    foreach(char c in inValue)&lt;br /&gt;        charArray[--length] = c;&lt;br /&gt;    &lt;br /&gt;    return new string(charArray);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public static string Reverse3(string inValue)&lt;br /&gt;{&lt;br /&gt;    char[] charArray = inValue.ToCharArray();&lt;br /&gt;    Array.Reverse(charArray);&lt;br /&gt;    &lt;br /&gt;    return new string(charArray);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public static string Reverse4(string str)&lt;br /&gt;{&lt;br /&gt;     char[] charArray = str.ToCharArray();&lt;br /&gt;     int len = str.Length - 1;&lt;br /&gt;            &lt;br /&gt;     for (int i = 0; i &lt; len; i++, len--)&lt;br /&gt;     {&lt;br /&gt;         charArray[i] ^= charArray[len];&lt;br /&gt;         charArray[len] ^= charArray[i];&lt;br /&gt;         charArray[i] ^= charArray[len];&lt;br /&gt;     }&lt;br /&gt;     return new string(charArray);&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;This question is very open ended and leading. It is open enough to see if you can entice the candidate to ask some questions about the functions possible use. The result is equally as useful. Some will use the C# library(Reverse, Reverse3) to help themselevs out. Others, usually with a C++ background, will code it with a simple for loop like in Reverse2. If they are really creative they will do some XOR Bit Shifting(Reverse4) &lt;a href="http://weblogs.sqlteam.com/mladenp/archive/2006/03/19/9350.aspx"&gt;(as I found demonstrated)&lt;/a&gt;. Equally, the question can be used to lead to such things as Big O notation or memory footprints etc. It is possible to mix it up a little as well asking them to check if the string is a palindrome etc.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Two lists Problem&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Given two lists remove all the values from the first list that are present in the second list.&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;public static IEnumerable&amp;lt;int&amp;gt; ConvertList(List&amp;lt;int&amp;gt; inMain, List&amp;lt;int&amp;gt; inExclude)&lt;br /&gt;{&lt;br /&gt;   return inMain.Except(inExclude);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public static List&amp;lt;int&amp;gt; ConvertList2(List&amp;lt;int&amp;gt; inMain, List&amp;lt;int&amp;gt; inExclude)&lt;br /&gt;{&lt;br /&gt;    foreach (var i in inExclude)&lt;br /&gt;        inMain.Remove(i) ;&lt;br /&gt;&lt;br /&gt;    return inMain;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public static List&amp;lt;int&amp;gt; ConvertList3(List&amp;lt;int&amp;gt; inMain, List&amp;lt;int&amp;gt; inExclude)&lt;br /&gt;{&lt;br /&gt;    bool found;&lt;br /&gt;    List&amp;lt;int&amp;gt; newList = new List&amp;lt;int&amp;gt;();&lt;br /&gt;    foreach (var im in inMain)&lt;br /&gt;    {&lt;br /&gt;        found = false;&lt;br /&gt;        foreach (var ie in inExclude)&lt;br /&gt;        {&lt;br /&gt;            if (im == ie)&lt;br /&gt;                found = true;&lt;br /&gt;            &lt;br /&gt;        }&lt;br /&gt;        if(!found)&lt;br /&gt;            newList.Add(im);&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;    return newList;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;This is not my favourite question but a lot of candidates either wont be able to answer it or will come up with an implementation like shown in example 3 which is generally a bad sign. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;Bonus&lt;/b&gt;&lt;br /&gt;Given an Integer how would you store multiple boolean values.&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;&lt;br /&gt;[Flags]&lt;br /&gt;public enum Permissions&lt;br /&gt;{&lt;br /&gt;    Read = 1,&lt;br /&gt;    Write = 2,&lt;br /&gt;    Update = 4,&lt;br /&gt;    RunScripts = 8,&lt;br /&gt;    All = Read | Write | Update | RunScripts,&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;I really don't consider this a very good opening question but it &lt;i&gt;could&lt;/i&gt; be asked at some point during the interview process to get an idea of overall knowledge.&lt;br /&gt;&lt;br /&gt;I think the idea behind FizzBuzz is a great one, however, if you are truly interested in not  wasting time then it isn't enough to just find out if they can code a simple problem. You need to use that simple problem to extract as much information as possible in the shortest amount of time.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6349904622030791405-2818279091049447630?l=blog.frozzn.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.frozzn.com/feeds/2818279091049447630/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.frozzn.com/2010/03/fizzbuzz-type-interview-questions.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/2818279091049447630" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/2818279091049447630" /><link rel="alternate" type="text/html" href="http://blog.frozzn.com/2010/03/fizzbuzz-type-interview-questions.html" title="Better then FizzBuzz" /><author><name>cgreeno</name><uri>http://www.blogger.com/profile/18114822473402093049</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6349904622030791405.post-1954821586690215608</id><published>2010-02-16T18:41:00.019Z</published><updated>2010-05-26T22:30:58.666+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Rant" /><title type="text">Are you a Senior Developer?</title><content type="html">&lt;span style="font-weight:bold;"&gt;Accountability in the Software Industry&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The general mentality of software industry is fundamentally flawed by arrogance, misunderstanding and lack of accountability. Making bad software is easy, anyone can do it. If you don't think you have ever done it, then you are still doing it. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;Managers And Team Leaders&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Sadly the same thing that makes a good manager is what makes a bad one. Ego. It makes you believe in yourself and your ideas enough to make the tough architectural decisions that need to be made. However, bad managers have some additional traits. Usually they have been been working for the same company for a number of years and have some glorified self important title like "Chief Software Architect" or some BS like that. These people will generally have some over the top coding standards that force upon developers like still insisting they use &lt;a href="http://en.wikipedia.org/wiki/Hungarian_notation"&gt;Hungarian notation&lt;/a&gt; despite the fact you have been using C# or Java for the last 5 years because it was they used in University. This, however, is where the personalities diverge into 2 types. &lt;br /&gt;&lt;br /&gt;Personality 1(The Obsolete):&lt;br /&gt;&lt;br /&gt;The easiest way to spot these people is ask them what they think about the new [insert random technology reference]. They will NEVER know what you are talking about. They are the "Chief Software Architect" they don't need to know little things like what you can and cant do with a language, details details details. &lt;br /&gt;&lt;br /&gt;Personality 2(Loves Shiny Things):&lt;br /&gt;&lt;br /&gt;Personality two is a bit harder to spot, it requires some digging. Generally the easiest way to spot these people is ask them what they think about a new technology that they think they know quite well and see how they have chosen to implement it. They will usually have gone the route of early optimization, not have a clear understanding WHY and WHEN to use something. A little more digging will reveal that they also don't understand basic things like unit or integration testing and they are usually fond of a multi-threaded solution. &lt;br /&gt;&lt;br /&gt;Well both these people are responsible for not only creating bad software but the future generation of developers. These developers then leave and think that is how software development is meant to be done. Its creating a broken industry. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Senior Developers&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;How many industries do you know where your are considered "Senior" after 2 years. None. Its ridiculous to think that your are Senior anything after 2 years in any industry. Ego makes people want to achieve that goal as quickly as possible, and ego is what they gain from it. Arrogance and ignorance can be very dangerous. We are now in the age where writing bad software can kill people, lose millions and cause untold chaos. You know who is writing this software.... Senior Developers. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;You Signed It&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Making good software is hard. It requires practice discipline and EDUCATION. Just like any other industry, the software industry should have a board and a apprenticeship program that requires you to understand industry practices that should be renewed every X number of years. If a building falls down who gets blamed? The Architect. If your new car breaks down who gets blamed? The Manufacturer. If your software doesn't work who do you blame? Blame yourself you signed the EULA.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6349904622030791405-1954821586690215608?l=blog.frozzn.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.frozzn.com/feeds/1954821586690215608/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.frozzn.com/2010/02/are-you-senior-developer.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/1954821586690215608" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/1954821586690215608" /><link rel="alternate" type="text/html" href="http://blog.frozzn.com/2010/02/are-you-senior-developer.html" title="Are you a Senior Developer?" /><author><name>cgreeno</name><uri>http://www.blogger.com/profile/18114822473402093049</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6349904622030791405.post-2392838938068668236</id><published>2010-01-23T18:42:00.006Z</published><updated>2010-03-20T02:19:23.277Z</updated><category scheme="http://www.blogger.com/atom/ns#" term="Bug" /><title type="text">Reshaper and F# Remapping the Shortcuts</title><content type="html">I installed F# the other day and when I went to fire up the interactive window I thought wait this seems really familiar... I am sure I use this command for something else, sure enough I was correct, it is a Resharper shortcut for quick edit.&lt;br /&gt;&lt;br /&gt;Fortunately, as of version 1.9.9, they have made the shortcut super easy to find by calling it &lt;blockquote&gt;EditorContextMenus.CodeWindow.SendToInteractive&lt;/blockquote&gt;In version 1.9.4 it WAS called &lt;blockquote&gt;Microsoft.Fsharp.Compiler.VSFSI.Connecdt.ML.SendSelection &lt;/blockquote&gt;but I guess having the words FSharp in the name made it too easy to identify. If you too need to remap it go to Tools --&gt; Options --&gt; Environment --&gt; Keyboard and type "SendTo" or "SendLine" to remap your F# interactive shortcut!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6349904622030791405-2392838938068668236?l=blog.frozzn.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.frozzn.com/feeds/2392838938068668236/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.frozzn.com/2010/01/reshaper-and-f.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/2392838938068668236" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/2392838938068668236" /><link rel="alternate" type="text/html" href="http://blog.frozzn.com/2010/01/reshaper-and-f.html" title="Reshaper and F# Remapping the Shortcuts" /><author><name>cgreeno</name><uri>http://www.blogger.com/profile/18114822473402093049</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6349904622030791405.post-5211808241912876135</id><published>2010-01-11T12:24:00.001Z</published><updated>2010-03-07T18:41:55.997Z</updated><category scheme="http://www.blogger.com/atom/ns#" term="Rant" /><title type="text">When to use a Window Services</title><content type="html">Why does everything need to be a service? Almost every company I have worked for has requested some kind of automated process. Anything from a nightly ftp upload to cleaning up some DB records. Sure enough someone always suggests a windows service. &lt;br /&gt;&lt;br /&gt;Windows says a service is:&lt;br /&gt;&lt;blockquote&gt;A program, routine, or process that performs a specific system function to support other programs, particularly at a low (close to the hardware) level. When services are provided over a network, they can be published in Active Directory, facilitating service-centric administration and usage. Some examples of services are the Security Accounts Manager service, File Replication service, and Routing and Remote Access service.&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Console App and the Windows Scheduler &lt;br /&gt;Windows has a built in scheduler that is perfect for TIMED jobs, that in combination with the a simple console app is perfect for these types of requests. Simple to build, simple to debug, simple to deploy and simple to maintain. What asset does it bring to the business to create a Service? Most of the time the person doing the recommending either doesn't really know what a service is for or they are just attempting to challenge themselves? Console apps are so much better in most cases. You can kick off a console app whenever you want, you can change it and work with it on the fly, rerun it whenever you want, and generally speaking you are going have a harder time accidental bringing down a server with a console app &lt;br /&gt;&lt;br /&gt;99% of the time a console app is going to be less intense on the server then a service especially if that service is poorly written, like the person that suggests we build a service with a timer to kick off processes, probably should not be your first choice of someone to take advice from. &lt;br /&gt;&lt;br /&gt;Windows Services &lt;br /&gt;Windows Services can be very useful and necessary but like everything it needs to be used when the business needs actually justify it. If you need to monitor a directory, use a service. If something on the server needs to up and running at all times, use a service. Services do have some built in advantages over a console app such as failure recovery. Such as "do nothing", "restart the service", "run a different app" or "restart the computer". I personally love the restart the computer option. &lt;br /&gt;&lt;br /&gt;Both Windows Services and console/windows scheduler have their place just be sure you have a think about what you really need and how much business value the service your itching to build really brings.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6349904622030791405-5211808241912876135?l=blog.frozzn.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.frozzn.com/feeds/5211808241912876135/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.frozzn.com/2010/02/when-to-use-window-services.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/5211808241912876135" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/5211808241912876135" /><link rel="alternate" type="text/html" href="http://blog.frozzn.com/2010/02/when-to-use-window-services.html" title="When to use a Window Services" /><author><name>cgreeno</name><uri>http://www.blogger.com/profile/18114822473402093049</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6349904622030791405.post-8084138056830243891</id><published>2009-06-28T14:38:00.002+01:00</published><updated>2010-03-28T14:40:08.826+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Stacked" /><title type="text">Caching in .NET</title><content type="html">As applications grow it is quite normal to leverage caching as a way to gain scalability and keep consistent server response times. Caching works by storing data in memory to drastically decrease access times. To get started I would look at ASP.NET caching.&lt;br /&gt;&lt;br /&gt;There are 3 types of general Caching techniques in ASP.NET web apps:&lt;br /&gt;&lt;br /&gt;Page Output Caching(Page Level)&lt;br /&gt;Page Partial-Page Output(Specific Elements of the page)&lt;br /&gt;Programmatic or Data Caching&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Output Caching&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;Page level output caching caches the html of a page so that each time ASP.NET page requested it checks the output cache first. You can vary these requests by input parameters(&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.ui.outputcacheparameters.varybyparam.aspx"&gt;VaryByParam&lt;/a&gt;) so the the page will only be cached for users where ID=1 if a requests come in where ID=2 asp.net cache is smart enough to know it needs to re-render the page.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Partial-Page Caching&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;a lot of times it wont make sense to cache the entire page in these circumstances you can use partial Page caching. This is usually used with user controls and is set the same way as page level only adding the OutputCache declarative inside the usercontrol.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Data Caching&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;You can store objects or values that are commonly used throughout the application. It can be as easy to as:&lt;br /&gt;&lt;br /&gt;Cache["myobject"] = person;&lt;br /&gt;Enterprise Level Caching&lt;br /&gt;&lt;br /&gt;It is worth mention that there are many Enterprise level caching architectures that have come about to leverage the effectiveness caching. &lt;a href="http://sourceforge.net/projects/memcacheddotnet/"&gt;Memcache &lt;/a&gt;for .net and &lt;a href="http://msdn.microsoft.com/en-us/data/cc655792.aspx"&gt;Velocity &lt;/a&gt;are a couple.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;In General&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;You can't really make blanket statements on what you should and shouldn't cache because every application is different. However, you can make a few generalizations that hold true MOST of time. Static elements like images and content are OK to cache. Even a dynamic page that is getting hammered is worth caching for 5-10 seconds, it will make a world of difference to your web server.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/kb/kb00323290.aspx"&gt;Caching overview&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6349904622030791405-8084138056830243891?l=blog.frozzn.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.frozzn.com/feeds/8084138056830243891/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.frozzn.com/2010/03/caching-in-net.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/8084138056830243891" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/8084138056830243891" /><link rel="alternate" type="text/html" href="http://blog.frozzn.com/2010/03/caching-in-net.html" title="Caching in .NET" /><author><name>cgreeno</name><uri>http://www.blogger.com/profile/18114822473402093049</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6349904622030791405.post-374901419784851367</id><published>2009-05-14T23:40:00.001+01:00</published><updated>2010-03-07T18:41:44.424Z</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><title type="text">Inline Functions in C#</title><content type="html">&lt;span style="font-weight: bold;"&gt;What are They?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In the terms of C and C++ you use the inline keyword to tell the compiler to call a routine without the overhead of pushing parameters onto the stack. The Function instead has it's machine code inserted into the function where it was called. This can create a significant increase in performance in certain scenarios.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Dangers&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The speed benefits in using "inlineing" decrease significantly as the size of the inline function increases. Overuse can actaully cause a program to run slower. Inlining a very small accessor function will usually decrease code size while inlining a very large function can dramatically increase code size.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Inlining in C#&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In C# inlining happens at the JIT level in which the JIT compiler makes the decision. There is currently no mechanism in C# which you can explicitly do this.  If you wish to know what the JIT compiler is doing then you can call System.Reflection.MethodBase.GetCurrentMethod().Name at runtime. If the Method is inlined it will return the name of the caller instead.&lt;br /&gt;&lt;br /&gt;In C# you cannot force a method to inline but you can force a method not to. If you really need access to a specific callstack and you need to remove inlining you can use : &lt;span id="nsrTitle"&gt;&lt;strong&gt;MethodImplAttribute&lt;/strong&gt;&lt;/span&gt; with &lt;strong&gt;MethodImplOptions.NoInlining&lt;/strong&gt;.  In addition  if a method is declared as virtual  then it will also not be inlined by the JIT. The reason behind this is that the final target of the call is unknown.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blogs.msdn.com/davidnotario/archive/2004/11/01/250398.aspx"&gt;More on inline here&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6349904622030791405-374901419784851367?l=blog.frozzn.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.frozzn.com/feeds/374901419784851367/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.frozzn.com/2009/03/inline-functions-in-c.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/374901419784851367" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/374901419784851367" /><link rel="alternate" type="text/html" href="http://blog.frozzn.com/2009/03/inline-functions-in-c.html" title="Inline Functions in C#" /><author><name>cgreeno</name><uri>http://www.blogger.com/profile/18114822473402093049</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6349904622030791405.post-1706835182231259556</id><published>2009-04-13T18:42:00.004+01:00</published><updated>2010-03-07T18:41:31.908Z</updated><category scheme="http://www.blogger.com/atom/ns#" term="Rant" /><title type="text">The Evils of regions#region</title><content type="html">I still remember when I first used the region field, it was a happier time, I was blissfully unaware of the problems that regionalizing your code was creating, I think everyone was. I picture the region directive being added as almost an after thought. I see someone at Microsoft saying "wow this tool sure generated so butt ugly code cant we hide that?" Regions to the rescue! A region is a &lt;a href="http://msdn.microsoft.com/en-us/library/ed8yd1ha(VS.71).aspx"&gt;preprocessor directive&lt;/a&gt; that allows programmers to hide sections of there code by using #region and #endregion syntax.&lt;br /&gt;MSDN says:&lt;br /&gt;&lt;blockquote&gt;#region lets you specify a block of code that you can expand or collapse when using the outlining feature of the Visual Studio Code Editor.&lt;br /&gt;For example:&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;#region MyClass definition&lt;br /&gt;public class MyClass &lt;br /&gt;{&lt;br /&gt;static void Main() &lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;#endregion&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Regions the clean solution&lt;/span&gt;&lt;br /&gt;Now I know what you might be thinking. What is so bad about that? How could that little region be causing so many problems? It is only there to help clean up your code a little. Ahh but wait.  Lets take a closer look at that. It helps clean up your code. Does it? Or does it just make the code LOOK cleaner.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Regions making the ugly look pretty&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Sadly, the same thing that spawned the region directive is the same thing it is being misused for now. I will just make a little hack here or there add a region directive and everything will be OK. The sooner everyone stops using regions the sooner developers will stop thinking its Okay to sweep their hacks under a rug that I find myself constantly cleaning.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6349904622030791405-1706835182231259556?l=blog.frozzn.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.frozzn.com/feeds/1706835182231259556/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.frozzn.com/2009/04/evils-of-regionsregion.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/1706835182231259556" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/1706835182231259556" /><link rel="alternate" type="text/html" href="http://blog.frozzn.com/2009/04/evils-of-regionsregion.html" title="The Evils of regions#region" /><author><name>cgreeno</name><uri>http://www.blogger.com/profile/18114822473402093049</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6349904622030791405.post-5252794546398570035</id><published>2009-03-16T12:26:00.003Z</published><updated>2010-03-20T02:16:33.941Z</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><title type="text">Using Using</title><content type="html">Using should be used with anything that implements &lt;a href="http://msdn.microsoft.com/en-us/library/system.idisposable.aspx"&gt;IDisposable&lt;/a&gt;. The using syntax can be used as a way of defining a scope for anything that implements IDisposable. The using statement also ensures that Dispose is called if an exception occurs.&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;&lt;br /&gt;//the compiler will create a local variable &lt;br /&gt;//which will go out of scope outside this context &lt;br /&gt;using (FileStream fs = new FileStream(file, FileMode.Open))&lt;br /&gt;{&lt;br /&gt;    //do stuff&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Alternatively you could just use:&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;FileStream fs;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;    fs = new FileStream();&lt;br /&gt;    //do Stuff&lt;br /&gt;}&lt;br /&gt;finally&lt;br /&gt;{&lt;br /&gt;    if(fs!=null)&lt;br /&gt;        fs.Dispose();&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Extra reading from MSDN&lt;br /&gt;C#, through the .NET Framework common language runtime (CLR), automatically releases the memory used to store objects that are no longer required. The release of memory is non-deterministic; memory is released whenever the CLR decides to perform garbage collection. However, it is usually best to release limited resources such as file handles and network connections as quickly as possible.&lt;br /&gt;The using statement allows the programmer to specify when objects that use resources should release them. The object provided to the using statement must implement the IDisposable interface. This interface provides the Dispose method, which should release the object's resources.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6349904622030791405-5252794546398570035?l=blog.frozzn.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.frozzn.com/feeds/5252794546398570035/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.frozzn.com/2010/02/using-should-be-used-with-anything-that.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/5252794546398570035" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/5252794546398570035" /><link rel="alternate" type="text/html" href="http://blog.frozzn.com/2010/02/using-should-be-used-with-anything-that.html" title="Using Using" /><author><name>cgreeno</name><uri>http://www.blogger.com/profile/18114822473402093049</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6349904622030791405.post-494387886354643064</id><published>2009-02-02T12:20:00.002Z</published><updated>2010-03-20T02:15:29.361Z</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><title type="text">Fixing to be Unsafe</title><content type="html">The fixed statement is used in the context of the unsafe modifier. Unsafe declares that you are going use pointer arithmetic(eg: low level API call), which is outside normal C# operations. The fixed statement is used to lock the memory in place so the garbage collector will not reallocate it while it is still in use. You can’t use the fixed statement outside the context of unsafe.&lt;br /&gt;&lt;br /&gt;Example&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;&lt;br /&gt;public static void PointyMethod(char[] array)&lt;br /&gt;{&lt;br /&gt;   unsafe&lt;br /&gt;   {&lt;br /&gt;        fixed (char *p = array)&lt;br /&gt;        {&lt;br /&gt;            for (int i=0; i&amp;lt;array.Length; i++)&lt;br /&gt;            {&lt;br /&gt;                System.Console.Write(*(p+i));&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6349904622030791405-494387886354643064?l=blog.frozzn.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.frozzn.com/feeds/494387886354643064/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.frozzn.com/2010/02/fixing-to-be-unsafe.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/494387886354643064" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/494387886354643064" /><link rel="alternate" type="text/html" href="http://blog.frozzn.com/2010/02/fixing-to-be-unsafe.html" title="Fixing to be Unsafe" /><author><name>cgreeno</name><uri>http://www.blogger.com/profile/18114822473402093049</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6349904622030791405.post-8053135165397330247</id><published>2009-01-22T20:49:00.003Z</published><updated>2010-05-26T22:34:45.383+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Rant" /><title type="text">Open Source is the root of all Evil</title><content type="html">We don't use open source.&lt;br /&gt;&lt;br /&gt;I hear this all the time and is always accompanied with a look of pride and a slight gloat. I can understand I guess. I was young once but more and more of these people are in there 30's, 40's and 50's.  So I turn to them and ask "So ahh Bill,  how long you been with X?" 10 years + is always the answer. Ahhh... the institutionalized then.&lt;br /&gt;&lt;br /&gt;&lt;font style="font-weight: bold;"&gt;Enterprise Risk &lt;/font&gt;&lt;br /&gt;&lt;br /&gt;Enterprise Risk&lt;font style="font-weight: bold;"&gt;  &lt;/font&gt;is the  number one reason given. Do the people that say this even know what that &lt;a href="http://en.wikipedia.org/wiki/Enterprise_Risk_Management"&gt;means&lt;/a&gt;? I would have thought it meant assessing risks in a pragmatic way to avoid any loss for your company. OK lets take this scenario. Say I'm doing some financial transactions using .Net on Server 2008 with MSSQL. It goes wrong. O CRAP!  Who's fault is it? Who do we blame? Where do we point the finger? Microsoft? Even if there is a hidden bug that has been documented it is still the developers fault. No ifs, ands or buts. &lt;a href="http://www.codinghorror.com/blog/archives/001079.html"&gt;The first rule in programming is its always the developers fault.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;font style="font-weight: bold;"&gt;Open Source is the root of all Evil&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;This is something that I have heard for years and I firmly blame the Microsoft  "Sales Pitch" for this.  Microsoft has been implying, if not outright saying, that if you use open source you are more likely to get attacked because it is less secure.  It's how they sell their products and services and it filters from the boardrooms to the mangers and so on. The biggest and most common misconception is: "Anyone can change the Source".&lt;br /&gt;&lt;br /&gt;&lt;font style="font-weight: bold;"&gt;No&lt;/font&gt;. &lt;font&gt;Not just anyone can change the source on the base version that is released to the public&lt;/font&gt;&lt;font style="font-weight: bold;"&gt;. &lt;/font&gt;While it is true you can download and change whatever your like, that change will not be reflected in the version that is distributed to the public. It boggles my mind how people cannot see the beauty in that...&lt;br /&gt;&lt;br /&gt;Lets roll back a moment to our 'O CRAP' financial  transaction.  Lets pretend the problem was in a MS library.  Lets take a real leap and say that it's open source. So as a developer we need to fix the problem to make it go away. So we pull the source down to make a change  and submit it to the project administrators. They say thank you. Check and scrutinize what you have done. Test our change and release it to the public. No more problem for me, or anyone else. It doesn't become a piece of obscure documentation that is in a knowledge base that has well over a million articles.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;font style="font-weight: bold;"&gt;Open Source Tools Libraries&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;I really believe that a lot of the open source tools/technologies are much better then those that that you have to pay fo, Sourcesafe being the most obvious example. Subversion and GIT(just to name two) are heads above Sourcesafe. Other tools such as &lt;a href="http://tortoisesvn.net/"&gt;TortoiseSVN&lt;/a&gt; intergate into windows to help users that perfer UI to commandline.&lt;br /&gt;&lt;br /&gt;Nunit, NHibernate, Rhino Mocks and Structure map, to name a few, are awesome open source liabaries that can only aid a developer. There are hundreds of these tools out there that a lot of developers are not able to use due to out dated company policies. Big compaines like microsoft end support for things all the time&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;What are these strange things?  Where did they come from? How long have then been around?  How did I function before these? Microsoft has just released competing version of these products. But really how well is V1 going to be? Nunit is on version 2.5 and Nhibernate on 2. Do you really think Microsoft is going to do a better job than the whole open source community working on these products for years?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;font style="font-weight: bold;"&gt;No Open Source allowed here&lt;/font&gt;  &lt;p&gt;Most of the large companies stand by their "No Open Source Rule" usually  citing support and maintenance. But big companies like Microsoft end support for things all the time the only difference is with an open source product you can continue to upgrade and update you are not forced onto an entirely different stack/server/library ect. I have to admit though I used to buy into the whole "open source is insecure mumbo jumbo" and stuck strictly to MS libraries.   But hey I also used to masturbate a whole lot more before I could find a woman that would sleep with me.... What's my point? If you're refuse to use open source then you're only screwing yourself. &lt;/p&gt;&lt;font style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/font&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6349904622030791405-8053135165397330247?l=blog.frozzn.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.frozzn.com/feeds/8053135165397330247/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.frozzn.com/2009/03/we-are-microsoft-only-shop.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/8053135165397330247" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/8053135165397330247" /><link rel="alternate" type="text/html" href="http://blog.frozzn.com/2009/03/we-are-microsoft-only-shop.html" title="Open Source is the root of all Evil" /><author><name>cgreeno</name><uri>http://www.blogger.com/profile/18114822473402093049</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6349904622030791405.post-3920888201320345516</id><published>2009-01-05T20:49:00.001Z</published><updated>2010-03-07T18:40:03.977Z</updated><category scheme="http://www.blogger.com/atom/ns#" term="article" /><title type="text">BOO Who?</title><content type="html">Anybody that reads &lt;a href="http://ayende.com/Blog/Default.aspx"&gt;Ayede Rahien's&lt;/a&gt; blog will notice that he is writing a book called &lt;a href="http://www.manning.com/rahien/"&gt;Building Domain Specific Languages with BOO&lt;/a&gt;. What? BOO? What the hell is BOO? I am a big fan of Anede and quickly wanted to get up to speed with BOO and what it is all about. Most of the my initial reading was taken right off the&lt;a href="http://boo.codehaus.org/"&gt; BOO website&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;Boo is a new object oriented statically typed programming language for the &lt;a href="http://boo.codehaus.org/Common+Language+Infrastructure" title="Common Language Infrastructure"&gt;Common Language Infrastructure&lt;/a&gt; with a &lt;a href="http://www.python.org/"&gt;python&lt;/a&gt; inspired syntax and a special focus on language and compiler extensibility.&lt;/blockquote&gt;GREAT! I Love python's syntax!  Who needs all those brackets anyway. But why do we need a whole new language to do Domain Specific Programming? And wait, what's up with Iron Python are these two not destine to clash? What am I not understanding here?&lt;br /&gt;&lt;br /&gt;IronPython is not a take on Python it is just a reimplementation of python, where as BOO is completely different Language that is based off python syntax. Boo is statically typed, while IronPython is dynamical typed. OK, they are not even close to the same thing. Its another one of the those classic programming examples where upon first glance something that looks like a snake and moves like a snake but is actually some type of &lt;a href="http://boo.codehaus.org/Duck+Typing"&gt;Duck&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;OK! Then the difference has to be with the fact it is a Domain Specific Language. Hmmm "Domain Specific" I think I know what that means... but do I?? I mean I have heard the term thrown around and thought I had a grasp on it.  I must still be missing something.....&lt;br /&gt;&lt;br /&gt;Martin Fowler says&lt;br /&gt;&lt;blockquote&gt;Domain specific language (DSL) is a computer language that's targeted to a particular kind of problem, rather than a general purpose language that's aimed at any kind of&lt;br /&gt;software problem.&lt;/blockquote&gt;OK well that is kind of what I thought. SO if  company XYZ has a corporate policy that all phone numbers have to be 3 digits, why wouldn't I just create a method or an even better an extension method.  Seems pretty straight forward...&lt;br /&gt;&lt;br /&gt;But Wait is that really a DSL? If you dig into it there are 4 types of DSL(From Chapter one of building DSL's) External, Graphical, Fluent and Internal/Embedded. OK now we are getting into it.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;External is specifying everything from how an If statement works to operator semantics.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Graphical is a DSL that is not textual, but rather uses shapes and lines in order to express intent&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Fluent - are  interfaces are a way to structure your API in such a fashion that operations flow in a natural manner.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Embedded - Internal DSL are built on top of an existing language, but they don’t try to remain true to the original programming language syntax. They try to express things in a way that would make sense to both the author and the reader, not to the compiler.&lt;/li&gt;&lt;/ul&gt;Ayede Says:&lt;br /&gt;&lt;blockquote&gt;Extension methods and lambda expression will certainly help, but they will not change the fundamental syntax too much. There are better alternatives for writing Domain Specific Languages than C#.&lt;/blockquote&gt;&lt;blockquote&gt;A DSL should be readable for someone who is familiar with the domain, not the programming language. A DSL built on top of an existing language can also be problematic, since you want to limit the options of the language, in order to make it clearer in what is going on, rather than turn the DSL into a fully fledged programming language; we already have that in the base language, after all. The main purpose of an internal DSL is to reduce the amount of stuff that you need to make the compiler happy, and increase the clarity of the code in question.&lt;/blockquote&gt;&lt;br /&gt;So what does this all mean? Well it means he sold another book....&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="text-decoration: underline;"&gt;&lt;/span&gt;&lt;a href="http://ayende.com/Blog/Default.aspx"&gt; &lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6349904622030791405-3920888201320345516?l=blog.frozzn.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.frozzn.com/feeds/3920888201320345516/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.frozzn.com/2009/03/boo-who.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/3920888201320345516" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6349904622030791405/posts/default/3920888201320345516" /><link rel="alternate" type="text/html" href="http://blog.frozzn.com/2009/03/boo-who.html" title="BOO Who?" /><author><name>cgreeno</name><uri>http://www.blogger.com/profile/18114822473402093049</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry></feed>

