<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/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'><id>tag:blogger.com,1999:blog-9009200</id><updated>2011-04-22T00:44:45.843+01:00</updated><title type='text'>Mark A. Grant</title><subtitle type='html'>Business Logic</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://markagrant.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://markagrant.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>MAG</name><uri>http://www.blogger.com/profile/04468576656657088957</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>19</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-9009200.post-1916624650982522623</id><published>2007-06-23T21:43:00.000+01:00</published><updated>2007-06-23T22:05:30.123+01:00</updated><title type='text'>Searching Code</title><content type='html'>Integrated Development Environment's (IDE's) are stuck in the doldrums when it comes to finding the right bit of code for a job. Today's web 2.0 applications lead the way in information retrieval, but these tools are not available in the world of software development.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;IDE's today&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;Current IDE's are based heavily around directory structures (namespaces) for grouping similar code together. Think System.XYZ. They have some simple tools for following references, i.e. go to the definition of a function or find all references to a function, and a rudimentary search engine.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;The current state-of-the-art in Web 2.0 Information Retrieval&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;For large sets of data Search has kicked Directory structures into touch. Search however is not contextual (its dumb and has no understanding of context). This leads to billions of results may of which are irrelevant. Web 2.0 companies have tried to overcome this through tagging and mark-up (the Semantic Web), which has more meaning, but requires effort on the part of the user (i.e. adding that tag). This is being overcome by smart algorithms that personalise your information based on your previous history of activities - think Amazon and "People who read this also read....".&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;What are we missing??&lt;/strong&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt; &lt;strong&gt;Viewing related information to the task currently being undertaken -&lt;/strong&gt; hey, you are changing interface X - here are all the classes, which implement it. Or, you have just named a class Y here are all the other classes with similar names&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Better Search -&lt;/strong&gt; common can we get a "Code Rank" algorithm - here are the most popular functions/classes based on their links (references) - and don't give me "you need to decouple your code more", some algorithms are more fundamental - like adding to a list&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Personalised Search -&lt;/strong&gt; using the historical results from the work you are doing to hone your search into something useful.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Better Collaboration -&lt;/strong&gt; none of this I'm going to shove IM in a toolbar and let you get on with it. I want to get realtime visualisation of which of my team members are working on which bits of code etc&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;strong&gt;The Solution&lt;/strong&gt;&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Make the IDE a Web-App running on a server, with integrated backend into the Repository = Solves 4 for Collaboration and also Version Control&lt;/li&gt;&lt;li&gt;Builds all running on the Server-side = Faster Builds&lt;/li&gt;&lt;li&gt;UI update to include contextual results panes - Solves 1&lt;/li&gt;&lt;li&gt;Server-side search engine to cross correlate user's activity - Solves 2 and 3 for personalisation&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Of course, this does come with a downside - us developers like to have the fastest, the whizziest, pc beast on the block, and if its running like a webapp we're not going to get the budget - Damn!&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;Posting by Mark A Grant&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9009200-1916624650982522623?l=markagrant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markagrant.blogspot.com/feeds/1916624650982522623/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9009200&amp;postID=1916624650982522623' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/1916624650982522623'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/1916624650982522623'/><link rel='alternate' type='text/html' href='http://markagrant.blogspot.com/2007/06/searching-code.html' title='Searching Code'/><author><name>MAG</name><uri>http://www.blogger.com/profile/04468576656657088957</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>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9009200.post-3289997461382795930</id><published>2007-05-07T23:12:00.000+01:00</published><updated>2007-05-07T23:24:52.868+01:00</updated><title type='text'>Nesting Splitters</title><content type='html'>To recap on my previous post - C# provides the "yield" keyword that allows any function that returns an IEnumerable object to provide lazy iteration capability (a Custom Enumerator). This allows us to iterate across an array or list and filter elements, convert them to different types, aggregate them with another list etc.&lt;br /&gt;&lt;br /&gt;My last post detailed how to "Split" an IEnumerable into two separate mutually exclusive enumerators. I.e. the equivalent of an if-else statement acting on each element.&lt;br /&gt;&lt;br /&gt;At the end of the post I suggested that it would be great to output multiple enumerators i.e. the equivalent of if-then-else or switch type patterns. This may not be required as &lt;strong&gt;we can Nest Enumerators! &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;It goes like this:&lt;br /&gt;&lt;br /&gt;inputList =&gt; split1 and split2 using our first test/predicate&lt;br /&gt;split1 =&gt; split3 and split4 using our second test/predicate on the results of split1&lt;br /&gt;&lt;br /&gt;We can then split the results add infinitum - creating a &lt;strong&gt;Binary Tree Splitter&lt;/strong&gt;. At each node in the tree we queue the results of the "lagging" enumerator until it catches up. &lt;strong&gt;What is the benefit?&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;We can split out multiple enumerators and process each of them differently.&lt;div class="blogger-post-footer"&gt;Posting by Mark A Grant&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9009200-3289997461382795930?l=markagrant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markagrant.blogspot.com/feeds/3289997461382795930/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9009200&amp;postID=3289997461382795930' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/3289997461382795930'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/3289997461382795930'/><link rel='alternate' type='text/html' href='http://markagrant.blogspot.com/2007/05/nesting-splitters.html' title='Nesting Splitters'/><author><name>MAG</name><uri>http://www.blogger.com/profile/04468576656657088957</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-9009200.post-2657042002979166649</id><published>2007-05-02T00:49:00.000+01:00</published><updated>2007-05-02T03:18:36.334+01:00</updated><title type='text'>Splitting an IEnumerable into Multiple Custom Iterators</title><content type='html'>Bill Wagners MSDN column on &lt;a href="http://msdn2.microsoft.com/en-us/vcsharp/bb264519.aspx"&gt;custom iterators&lt;/a&gt; is excellent. It demonstrates clearly how to create a custom iterator so that IEnumerable iterators can iterate through collections in a lazy fashion. That is only processing the elements in the collection that are required.&lt;br /&gt;&lt;br /&gt;As soon as it becomes evident that custom iterators take an IEnumerable as an input and output an IEnumerable it also becomes evident that we can "pipeline" custom iterators.&lt;br /&gt;&lt;br /&gt;For Example:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Start with a Collection of People&lt;/li&gt;&lt;li&gt;Filter out all people with surname Grant&lt;/li&gt;&lt;li&gt;Filter out all people with first name Mark&lt;/li&gt;&lt;li&gt;Display List of Results on screen&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;This is a simple pipeline like so: 1 -&gt; 2 -&gt; 3 -&gt; 4&lt;/p&gt;&lt;p&gt;We can also Transform iterators into different types and we can Merge or Aggregate multiple iterators into one be iterating over each in turn. This got me thinking is it possible to split an iterator into mutiple iterators.&lt;/p&gt;&lt;p&gt;By splitting an iterator it allows us to process the different sets of results differently. As an example:&lt;/p&gt;&lt;p&gt;We have an iterator that recurses a file structure. We need to split out two iterators -one for files and one for directories. &lt;/p&gt;&lt;p&gt;Out input iterator is of type IEnumerable&lt;filesysteminfo&gt; and splits into a directoryIterator and fileIterator of type IEnumerable&lt;filesysteminfo&gt;. These can then be Transformed into an IEnumerable&lt;directoryinfo&gt; and an IEnumerable&lt;fileinfo&gt; respectively.&lt;/p&gt;&lt;p&gt;Having asked Bill if he could blog a solution I had some inspiration! &lt;strong&gt;Here is a test case for the solution:&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;&lt;pre class="csharpcode"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; MarkGrant.Collections;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; NUnit.Framework;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Text;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; MarkGrantTest&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="rem"&gt;/// &lt;/span&gt;&lt;br /&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="rem"&gt;/// &amp;lt;originalAuthor&amp;gt;mark.grant&amp;lt;/originalAuthor&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="rem"&gt;/// &amp;lt;creationDate&amp;gt;01/05/2007 23:58:19&amp;lt;/creationDate&amp;gt;&lt;/span&gt;&lt;br /&gt;    [TestFixture]&lt;br /&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; TestSplitter&lt;br /&gt;    {&lt;br /&gt;        [Test]&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Test()&lt;br /&gt;        {&lt;br /&gt;            List&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt; list = &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt;();&lt;br /&gt;            &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; 20; i++)&lt;br /&gt;            {&lt;br /&gt;                list.Add(i);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// intialize our splitter&lt;/span&gt;&lt;br /&gt;            Splitter&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt; splitter = &lt;span class="kwrd"&gt;new&lt;/span&gt; Splitter&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt;(list, &lt;span class="kwrd"&gt;delegate&lt;/span&gt;(&lt;span class="kwrd"&gt;int&lt;/span&gt; number) { &lt;span class="kwrd"&gt;return&lt;/span&gt; number % 3 == 0; });&lt;br /&gt;            IEnumerable&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt; factor3 = splitter.GetMatchingElements();&lt;br /&gt;            IEnumerable&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt; nonFactor3 = splitter.GetNonMatchingElements();&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; factor &lt;span class="kwrd"&gt;in&lt;/span&gt; factor3)&lt;br /&gt;            {&lt;br /&gt;                Assert.IsTrue(factor % 3 == 0);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; nonFactor &lt;span class="kwrd"&gt;in&lt;/span&gt; nonFactor3)&lt;br /&gt;            {&lt;br /&gt;                Assert.IsTrue(nonFactor % 3 == 1  nonFactor % 3 == 2);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;The test creates a Splitter class that Matches multiples of 3 and non-multiples. The IEnumerables can be called in any order and can overlap. As we don't know which iterator will be called the splitter will need to record the current state of the two iterators - i.e. which elements are left, which iterator they are related too etc. This can be achieved by queuing elements that are requested but belong to the other iterator.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;The Splitter class:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Text;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; MarkGrant.Collections&lt;br /&gt;{&lt;br /&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="rem"&gt;/// Split an input enumerable into two mutually exclusive enumerables&lt;/span&gt;&lt;br /&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="rem"&gt;/// &amp;lt;typeparam name="T"&amp;gt;&amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Splitter&amp;lt;T&amp;gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// Are we queuing the results from the first enumerator or the second - it&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// depends on which one is ahead&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; _queuingFirstIterator;&lt;br /&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// We Queue one Enumerator unless the two are perfectly synchronised&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; Queue&amp;lt;T&amp;gt; _unyieldedElements = &lt;span class="kwrd"&gt;new&lt;/span&gt; Queue&amp;lt;T&amp;gt;();&lt;br /&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// Our filter&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; Predicate&amp;lt;T&amp;gt; _predicate;&lt;br /&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// Our input enumerator&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; IEnumerator&amp;lt;T&amp;gt; _inputEnumerator;&lt;br /&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// Construct our Splitter with the input enumerator and the filter&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="inputEnumerable"&amp;gt;the input enumerator&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="predicate"&amp;gt;our filter&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; Splitter(IEnumerable&amp;lt;T&amp;gt; inputEnumerable, Predicate&amp;lt;T&amp;gt; predicate)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (inputEnumerable == &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br /&gt;            {&lt;br /&gt;                &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; ArgumentNullException(&lt;span class="str"&gt;"inputEnumerable"&lt;/span&gt;);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (predicate == &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br /&gt;            {&lt;br /&gt;                &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; ArgumentNullException(&lt;span class="str"&gt;"predicate"&lt;/span&gt;);&lt;br /&gt;            }&lt;br /&gt;            _inputEnumerator = inputEnumerable.GetEnumerator();&lt;br /&gt;            _predicate = predicate;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// All elements that match the predicate&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; IEnumerable&amp;lt;T&amp;gt; GetMatchingElements()&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; GetNextElement(&lt;span class="kwrd"&gt;true&lt;/span&gt;);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// All elements that don't match the predicate&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; IEnumerable&amp;lt;T&amp;gt; GetNonMatchingElements()&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; GetNextElement(&lt;span class="kwrd"&gt;false&lt;/span&gt;);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// Returns the next element for our enumerator&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="isMatching"&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; IEnumerable&amp;lt;T&amp;gt; GetNextElement(&lt;span class="kwrd"&gt;bool&lt;/span&gt; isMatching)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;while&lt;/span&gt; (&lt;span class="kwrd"&gt;true&lt;/span&gt;)&lt;br /&gt;            {&lt;br /&gt;                &lt;span class="rem"&gt;// if we have an element in the queue for this iterator then&lt;/span&gt;&lt;br /&gt;                &lt;span class="rem"&gt;// yield it otherwise next element in the inputEnumerator is&lt;/span&gt;&lt;br /&gt;                &lt;span class="rem"&gt;// for this enumerable then yield it otherwise add it to the queue&lt;/span&gt;&lt;br /&gt;                &lt;span class="rem"&gt;// break when no more elements remain in either&lt;/span&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (_queuingFirstIterator == isMatching &amp;&amp;amp; _unyieldedElements.Count &amp;gt; 0)&lt;br /&gt;                {&lt;br /&gt;                    &lt;span class="kwrd"&gt;yield&lt;/span&gt; &lt;span class="kwrd"&gt;return&lt;/span&gt; _unyieldedElements.Dequeue();&lt;br /&gt;                }&lt;br /&gt;                &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (_inputEnumerator.MoveNext())&lt;br /&gt;                {&lt;br /&gt;                    &lt;span class="kwrd"&gt;if&lt;/span&gt; (_predicate(_inputEnumerator.Current) == isMatching)&lt;br /&gt;                    {&lt;br /&gt;                        &lt;span class="kwrd"&gt;yield&lt;/span&gt; &lt;span class="kwrd"&gt;return&lt;/span&gt; _inputEnumerator.Current;&lt;br /&gt;                    }&lt;br /&gt;                    &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;br /&gt;                    {&lt;br /&gt;                        _unyieldedElements.Enqueue(_inputEnumerator.Current);&lt;br /&gt;&lt;br /&gt;                        _queuingFirstIterator = !isMatching;&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;                &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;br /&gt;                {&lt;br /&gt;                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The Splitter class is initialized with the input IEnumerable and the Predicate that is used to filter the elements into the Matching and NonMatching itereators. As we enumerate through the input iterator, we keep iterating until we find an element that matches the one we are after, all the elements that we don't want we queue and a flag is set to record which iterator is "lagging" behind and therefore requires its elements to be queued.&lt;/p&gt;&lt;p&gt;We could for example alternate the requesting of results for either iterator. For example when matching factors of 3 starting with the iterator that matches 3, 6, 9 etc and an input list of 1,2,3,4,5,6 we get, where M is the Matching iterator (i.e. anything which is a factor of 3):&lt;/p&gt;&lt;ol&gt;&lt;li&gt;M - Queue (1) &lt;/li&gt;&lt;li&gt;Yield (1)&lt;/li&gt;&lt;li&gt;M - Queue (2)&lt;/li&gt;&lt;li&gt;Yield (2)&lt;/li&gt;&lt;li&gt;M - Yield (3)&lt;/li&gt;&lt;li&gt;Yield (4)&lt;/li&gt;&lt;li&gt;M - Queue (5)&lt;/li&gt;&lt;li&gt;Yield (5)&lt;/li&gt;&lt;li&gt;M - Yield (6)&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;If anyone fancies improving the code to include multiple predicates, please let me know.&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;Posting by Mark A Grant&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9009200-2657042002979166649?l=markagrant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markagrant.blogspot.com/feeds/2657042002979166649/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9009200&amp;postID=2657042002979166649' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/2657042002979166649'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/2657042002979166649'/><link rel='alternate' type='text/html' href='http://markagrant.blogspot.com/2007/05/splitting-ienumerable-into-multiple.html' title='Splitting an IEnumerable into Multiple Custom Iterators'/><author><name>MAG</name><uri>http://www.blogger.com/profile/04468576656657088957</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>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9009200.post-6394417821790320391</id><published>2007-04-10T19:23:00.000+01:00</published><updated>2007-04-10T19:26:56.896+01:00</updated><title type='text'>Great Web GUI article</title><content type='html'>&lt;a href="http://worrydream.com/MagicInk/"&gt;This article by Bret Victor&lt;/a&gt; really stands out when it comes to Web Usability. Not only is it well thought out and easy to read, but the main points are very well made.  Worth reading by anyone producing software that interacts (or not - see the article) with humans.&lt;div class="blogger-post-footer"&gt;Posting by Mark A Grant&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9009200-6394417821790320391?l=markagrant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markagrant.blogspot.com/feeds/6394417821790320391/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9009200&amp;postID=6394417821790320391' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/6394417821790320391'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/6394417821790320391'/><link rel='alternate' type='text/html' href='http://markagrant.blogspot.com/2007/04/great-web-gui-article.html' title='Great Web GUI article'/><author><name>MAG</name><uri>http://www.blogger.com/profile/04468576656657088957</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-9009200.post-6671481622397092308</id><published>2007-03-25T19:55:00.000+01:00</published><updated>2007-03-25T20:52:25.860+01:00</updated><title type='text'>Compression and Communication in Software Development</title><content type='html'>The process of refactoring software code is something akin to a compression algorithm.  As an example let us take a simple lossless image algorithm that takes runs of the same colour and stores the colour and the number of pixels in the run.  We can think of this as finding two functions that are the same, but with different names and creating 1 function and pointing the original two callers to the new function. This process is about abstraction.&lt;br /&gt;&lt;br /&gt;Fair enough you might say, but we can take this a bit further. Thinking about compression triggered some thoughts about Information theory I learnt at University. Namely, Shannon's Law- so I looked it up on Wikipedia, and here is what it had to say:-&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;it is a &lt;a title="Felony" href="http://en.wikipedia.org/wiki/Felony"&gt;felony&lt;/a&gt; offense to discharge &lt;a title="Firearms" href="http://en.wikipedia.org/wiki/Firearms"&gt;firearms&lt;/a&gt; randomly into the air, resulting in injury or death.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Err, ok maybe not that &lt;a href="http://en.wikipedia.org/wiki/Shannon%27s_law_%28Arizona%29"&gt;Shannon's Law (in Arizona&lt;/a&gt;). A little further digging on the right pages reveals Coding theory (no it not about programming!!!!!). Ah, and now I have found the bit of information I am after (and its a 1 - sorry poor joke -it's a Sunday evening!!!)&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Entropy of a source is the measure of information. Basically source codes try to reduce the redundancy present in the source, and represent the source with a fewer bits that carry more information.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;strong&gt;SOURCE ENCODING&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Translated to software development - there is a minimum number of lines of code required for each program, where there is absolutely no redundant code. This can commonly be seen in some coding competitions, where the winner of a challenge solves the problem in the fewest lines of code. &lt;/p&gt;&lt;p&gt;Putting aside readability, quality, comments, maintainability, the meaning of your code or communicating your code with other developers etc, we can surmise the following. When your code is represented in the most concise manner, no two lines or pieces of code should look the same, do the same thing or repeat any other lines of code. This is because any lines of code with the same data are redundant and do not transfer any new information to the compiler.  &lt;/p&gt;&lt;p&gt;So here is the problem, in many languages it is IMPOSSIBLE to make code concise and remove redundancy - thereby reducing the entropy of the code. Take for example design patterns, they are seriously REDUNDANT!!!! The mere fact that they exist, they provide the same construct in multiple scenarios really means they should have been written once, not millions of times by millions of developers!!! (Mind you I have now used generics to write a Singleton - ONCE)&lt;/p&gt;&lt;p&gt;C# has just created some "syntactic suger" to reduce the amount of code required to write a property, which meets one of the key tenets of Information Theory. Namely, use short words for the most frequently used words!&lt;/p&gt;&lt;p&gt;So, on the flip side, is:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;CHANNEL ENCODING&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;When communicating information we need to add redundant information to ensure our message is understood - think listening to a fuzzy radio station - sometimes it is possible to understand without hearing every word!&lt;/p&gt;&lt;p&gt;So, in programming terms, we have two key audiences/recipients for our code:-&lt;/p&gt;&lt;ol&gt;&lt;li&gt;The compiler&lt;/li&gt;&lt;li&gt;You, the developer, and other developers&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;We add large amounts of redundancy for comments and in terms of code structure in order to effectively communicate the meaning of our code. At this point, due to tiredness I am starting to forget what I really wanted to say! A quick wrap up and I'll think about it some more!!!&lt;/p&gt;&lt;p&gt;1. We can apply some of the theories of Information theory to Software development&lt;/p&gt;&lt;p&gt;2. We apply Source Encoding as we refactor/abstract our code&lt;/p&gt;&lt;p&gt;3. We apply Channel Encoding to improve the communication of our code&lt;/p&gt;&lt;p&gt;4. Finally, we are slaves to our compilers when it comes to removing redundant lines of code&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;Posting by Mark A Grant&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9009200-6671481622397092308?l=markagrant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markagrant.blogspot.com/feeds/6671481622397092308/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9009200&amp;postID=6671481622397092308' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/6671481622397092308'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/6671481622397092308'/><link rel='alternate' type='text/html' href='http://markagrant.blogspot.com/2007/03/compression-and-communication-in.html' title='Compression and Communication in Software Development'/><author><name>MAG</name><uri>http://www.blogger.com/profile/04468576656657088957</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>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9009200.post-1640531373544310364</id><published>2007-03-16T20:43:00.000Z</published><updated>2007-03-16T21:12:14.760Z</updated><title type='text'>Currying, Closures ad how to screw your mind in 1 line of code</title><content type='html'>Ok, so we can pass functions as data using delegates. I recently started using delegates as return values for functions, and this can lead to some odd syntax!&lt;br /&gt;&lt;br /&gt;So, the 1 line of code:&lt;br /&gt;&lt;br /&gt;int answer = Add(5)(3);&lt;br /&gt;&lt;br /&gt;Note the second set of brackets - where the hell did they come from!&lt;br /&gt;&lt;br /&gt;So here's the add function&lt;br /&gt;&lt;br /&gt;public static AddNumbers Add(int x)&lt;br /&gt;{&lt;br /&gt;   return delegate(int y) { return x + y;};&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;where AddNumber is a delegate (function pointer) defined as:&lt;br /&gt;&lt;br /&gt;public delegate int AddNumbers(int y);&lt;br /&gt;&lt;br /&gt;What the hell does this mean?&lt;br /&gt;&lt;br /&gt;When we call Add(5) we are doing two things:&lt;br /&gt;&lt;br /&gt;1. Setting the variable x within the anonymous function's return statement&lt;br /&gt;2. returning a function, which takes a parameter y&lt;br /&gt;&lt;br /&gt;As the return value of Add(5) is a function we can then call the function Add(5)(3); which will return the value 8!&lt;br /&gt;&lt;br /&gt;This leads to two important functional concepts:&lt;br /&gt;&lt;br /&gt;1. Currying - a function which takes multiple parameters can now be split into multiple functions each taking one parameter i.e. Add(int x, int y) becomes Add(int x) : return AddNumber(int y)&lt;br /&gt;using the stack to store the x variable&lt;br /&gt;&lt;br /&gt;2. Closures - the anonymous method can "see" the variables within the Add(int x) method of which it is a part - just like the contents of an if statement would.  The complexity here is when the anonymous function is returned from the Add function&lt;br /&gt;&lt;br /&gt;We can use currying to intialize parameters. So for example lets say we wanted to do the following sums:&lt;br /&gt;&lt;br /&gt;answer = 3 + 5&lt;br /&gt;answer = 3 + 7&lt;br /&gt;answer = 3 + 9&lt;br /&gt;&lt;br /&gt;rather than do:&lt;br /&gt;int answer1 = Add(3, 5);&lt;br /&gt;int answer2 = Add(3, 7);&lt;br /&gt;int answer3 = Add(3, 9);&lt;br /&gt;&lt;br /&gt;we can initialise the 3 parameter using the Add function, and rewrite our code as:&lt;br /&gt;&lt;br /&gt;AddNumbers adder = Add(3);&lt;br /&gt;int answer1 = adder(5);&lt;br /&gt;int answer2 = adder(7);&lt;br /&gt;int answer3 = adder(9);&lt;br /&gt;&lt;br /&gt;This becomes really useful when out initialization occurs in a different part of our code to the actual "running" of the code. It could also allow us to create an "immutable" function, where we initialize all of the functions parameters at one point in our code and return a parameterless function.&lt;div class="blogger-post-footer"&gt;Posting by Mark A Grant&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9009200-1640531373544310364?l=markagrant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markagrant.blogspot.com/feeds/1640531373544310364/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9009200&amp;postID=1640531373544310364' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/1640531373544310364'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/1640531373544310364'/><link rel='alternate' type='text/html' href='http://markagrant.blogspot.com/2007/03/currying-closures-ad-how-to-screw-your.html' title='Currying, Closures ad how to screw your mind in 1 line of code'/><author><name>MAG</name><uri>http://www.blogger.com/profile/04468576656657088957</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-9009200.post-4239712003531926244</id><published>2007-03-16T19:50:00.000Z</published><updated>2007-03-16T20:03:31.058Z</updated><title type='text'>Applying Control Theory to Software Development</title><content type='html'>Many moons ago I learnt control theory - possibly the hardest final year engineering paper at Cambridge. And it had the following to say:&lt;br /&gt;&lt;br /&gt;Every system can be treated as a black box with inputs and outputs - ok no revolution here, but I need a starting point!&lt;br /&gt;&lt;br /&gt;It also said:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Observability&lt;/strong&gt; is a measure for how well internal states of a system can be inferred by knowledge of its external outputs - thank you Wikipedia.&lt;br /&gt;&lt;br /&gt;and,&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Controllability&lt;/strong&gt; denotes the ability to move a system around in its entire configuration space using only certain admissible manipulations - Wikipedia's entry is not so helpful a translation would read how much of the output can we control using the inputs&lt;br /&gt;&lt;br /&gt;So, Observability is the ability to deduce whats going on inside by whats coming out - a bit like the stool analysis and Controllability is the ability to configure the system via inputs - the equivalent of the atkins diet.&lt;br /&gt;&lt;br /&gt;Now in software systems, we can apply the same ideas. Namely, when I write a chunk of code it is a black box system - stuff goes in and stuff comes out!!!!!&lt;br /&gt;&lt;br /&gt;In fact several programming techniques are based entierly on this principal, namely, Inversion of Control Design pattern, Test Driven Development and large chunks of Functional Programming concepts.&lt;br /&gt;&lt;br /&gt;In fact, my normal gripes with any framework (Java or .Net) typically occur when the code in the framework is not Observable or Controllable enough. In fact code can typically be improved by increasing ones ability to configure it and by providing clear outputs for given inputs!&lt;div class="blogger-post-footer"&gt;Posting by Mark A Grant&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9009200-4239712003531926244?l=markagrant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markagrant.blogspot.com/feeds/4239712003531926244/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9009200&amp;postID=4239712003531926244' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/4239712003531926244'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/4239712003531926244'/><link rel='alternate' type='text/html' href='http://markagrant.blogspot.com/2007/03/applying-control-theory-to-software.html' title='Applying Control Theory to Software Development'/><author><name>MAG</name><uri>http://www.blogger.com/profile/04468576656657088957</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-9009200.post-3805378559744122761</id><published>2007-03-03T18:51:00.000Z</published><updated>2007-03-03T19:37:46.491Z</updated><title type='text'>delegates and interfaces</title><content type='html'>In trying to explain some functional concepts in C# to an OO programmer, it became apparent that there is a quite clear correspondance between an interface and a delegate (function pointer).&lt;br /&gt;&lt;br /&gt;The following is a list of comparisons:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;An interface provides a level of indirection/abstraction for a class - a delegate provides a level of indirection/abstraction for a function&lt;/li&gt;&lt;li&gt;An interface provides signatures for a bunch of functions/properties - a delegate provides signatures for a function&lt;/li&gt;&lt;li&gt;both can be passed as variables&lt;/li&gt;&lt;li&gt;An interface will only work with an object, whereas a delegate can work with static and instance methods&lt;/li&gt;&lt;li&gt;Finally, delegates can be "invoked" or called asynchronously&lt;/li&gt;&lt;li&gt;An interface quite clearly relates to a class&lt;/li&gt;&lt;li&gt;An class can only implement an interface once, but can have many functions, which match a delegate&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;In many cases a delegate can provide simpler implementation than an interface, especially when the function is stateless and can therefore be made static therefore reducing side-effects. Its food for thought anyway!&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;Posting by Mark A Grant&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9009200-3805378559744122761?l=markagrant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markagrant.blogspot.com/feeds/3805378559744122761/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9009200&amp;postID=3805378559744122761' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/3805378559744122761'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/3805378559744122761'/><link rel='alternate' type='text/html' href='http://markagrant.blogspot.com/2007/03/delegates-and-interfaces.html' title='delegates and interfaces'/><author><name>MAG</name><uri>http://www.blogger.com/profile/04468576656657088957</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>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9009200.post-6222864399016858665</id><published>2007-01-25T22:09:00.000Z</published><updated>2007-01-25T22:41:57.267Z</updated><title type='text'>F#</title><content type='html'>Having spent a good few hours looking into functional programming -&gt; and what a revelation it has been. I thought I would scout out F#. F# is a functional language (with object-orientated and imperative coding acceptable as well) based on top of .Net. I am not sure whether adoption of F# will be very high as C# and VB.Net are going functional (more so) in .Net 3.0 with support for lambda expressions and LINQ.&lt;br /&gt;&lt;br /&gt;Even more interesting was finding out that the key developers of the language are based at Microsoft, Cambridge, which is just down the road from me. &lt;a href="http://research.microsoft.com/fsharp/fsharp.aspx"&gt;Their research homepage is here&lt;/a&gt; and the &lt;a href="http://blogs.msdn.com/dsyme/"&gt;lead developer Don Syme's blog is here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Whilst I'm at it here are the sites of some of the guys I know at Microsoft, Cambridge. They are worth looking at for the &lt;a href="http://research.microsoft.com/vision/cambridge/"&gt;cool research in Machine learning and vision&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://johnwinn.org/"&gt;John Winn's homepage&lt;/a&gt;&lt;br /&gt;&lt;a href="http://mi.eng.cam.ac.uk/~omcw2/"&gt;Oli Williams Cambridge University page&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;Posting by Mark A Grant&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9009200-6222864399016858665?l=markagrant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markagrant.blogspot.com/feeds/6222864399016858665/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9009200&amp;postID=6222864399016858665' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/6222864399016858665'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/6222864399016858665'/><link rel='alternate' type='text/html' href='http://markagrant.blogspot.com/2007/01/f.html' title='F#'/><author><name>MAG</name><uri>http://www.blogger.com/profile/04468576656657088957</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-9009200.post-116768317084168045</id><published>2007-01-01T19:42:00.000Z</published><updated>2007-01-01T20:26:10.903Z</updated><title type='text'>Using Code Generation for Dynamic Proxies</title><content type='html'>Having given code generation a hard time in a &lt;a href="http://markagrant.blogspot.com/2006/12/visual-studio-templates-and-code.html"&gt;previous post&lt;/a&gt;, there is one area, where I can definitely see Code Generation providing a valuable solution - Dynamic Proxies. Code Generation typically falls short because it is used within the design cycle and is a bit like baking a cake - its a bit hard to add raisins once you've baked it! With Dynamic Proxies however Code Generation is used at runtime and is a whole different kettle of fish.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;What are Proxies? &lt;/strong&gt;You have a class, which you would like to serialize, add security, logging or maybe even thread locking. In each of these scenarios you typically which to apply logic to public properties and methods (although it is sometimes necessary to serialize private fields). A proxy class will encapsulate our class and expose the classes methods itself, typically by implementing the same interface as the class.&lt;br /&gt;&lt;br /&gt;An example:&lt;br /&gt;&lt;br /&gt;// class stub&lt;br /&gt;public class Person implements IPerson&lt;br /&gt;{&lt;br /&gt;public String Fullname;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// proxy stub&lt;br /&gt;public class ProxyPerson implements IPerson&lt;br /&gt;{&lt;br /&gt;public IPerson Person;&lt;br /&gt;&lt;br /&gt;public String Fullname&lt;br /&gt;{&lt;br /&gt;// some proxy logic&lt;br /&gt;return Person.FullName;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;The Person class implements the IPerson interface and the proxy class also implements IPerson interface as well as exposing the original Person class.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;What is a Dynamic Proxy?&lt;/strong&gt; Simple a proxy class generated dynamically at Runtime.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;How does it work?&lt;/strong&gt; We specify the class we wish to generate a proxy for. In .Net this is achieved by decorating the class and its methods with &lt;a href="http://www.devarticles.com/c/a/ASP.NET/Demonstrating-Attributes-and-Reflection-in-.NET/1/"&gt;Attributes&lt;/a&gt; (does Java have attributes?) When we run our code our proxy generator then reads the attributes and uses them to generate the proxy class e.g.&lt;br /&gt;&lt;br /&gt;IPerson personProxy = ProxyGenerator.Proxy(new Person());&lt;br /&gt;&lt;br /&gt;We can then us the personProxy instead of the original class.&lt;br /&gt;&lt;br /&gt;This sort of technique could also allow us to decouple other functionality from a class such as Equals, GetHashCode, Clone etc leaving our core class less cluttered with Utility functions.&lt;br /&gt;&lt;br /&gt;The Person example with Attributes:&lt;br /&gt;&lt;br /&gt;// class stub&lt;br /&gt;public class Person implements IPerson&lt;br /&gt;{&lt;br /&gt;[RequiredForEquals()]&lt;br /&gt;public String Fullname;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;All properties marked with a RequiredForEquals Attribute can be picked up and compared. The comparison code would look something like:&lt;br /&gt;&lt;br /&gt;Equalizer personEqualizer = new Equalizer(typeof(Person));&lt;br /&gt;&lt;br /&gt;personEqualizer.Equals(person1, person2);&lt;br /&gt;&lt;br /&gt;Behind the scenes the Equalizer would use Reflection to read the Attribute and Code Generation to generate our Equlas code before the Equals operation is performed.&lt;br /&gt;&lt;br /&gt;// class stub&lt;br /&gt;public class Person implements IPerson&lt;br /&gt;{&lt;br /&gt;public String Fullname;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;But I can do this with Reflection only!&lt;/strong&gt; Yup, but Reflecting over a bunch of classes, methods and attributes takes time - generating the proxy and caching it can allow the same proxy to be reused over and over again, with a little overhead on the proxy generation.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Performance&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;Both Reflection and Code Generation are costly operations, and therefore not something to be undertaken lightly, however, for all but the most time critical functionality they can be optimised by creating the equalizer when the program is loaded (by making the equalizer static).&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;A real life example&lt;/strong&gt;, to the best of my knowledge this is how the .Net Frameworks XmlSerializer works. By making the serializer static I managed to improve my serialization code by ten times (originally a 3 second operation became a 0.3 second operation - a significant improvement!)&lt;br /&gt;&lt;br /&gt;I have been tempted, but not found time/reason to create a library for creating dynamic proxies. IBM has a interesting Java post on &lt;a href="http://www-128.ibm.com/developerworks/library/j-jtp08305.html"&gt;this very topic&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;Posting by Mark A Grant&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9009200-116768317084168045?l=markagrant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markagrant.blogspot.com/feeds/116768317084168045/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9009200&amp;postID=116768317084168045' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/116768317084168045'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/116768317084168045'/><link rel='alternate' type='text/html' href='http://markagrant.blogspot.com/2007/01/using-code-generation-for-dynamic.html' title='Using Code Generation for Dynamic Proxies'/><author><name>MAG</name><uri>http://www.blogger.com/profile/04468576656657088957</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-9009200.post-116750446956010952</id><published>2006-12-30T15:43:00.000Z</published><updated>2006-12-30T18:47:50.030Z</updated><title type='text'>Contracts in Object Orientated Code</title><content type='html'>A school of thought, which is widely supported, suggests that when two pieces of code communicate they form a contract. That is if code A ("the client") calls code B ("the supplier") with some data it will expect code B to have certain behaviour, return certain data and handle exceptional/erroneous/odd inputs in a certain way. The idea is called "&lt;a href="http://en.wikipedia.org/wiki/Design_by_contract"&gt;Design by Contract&lt;/a&gt;" (DBC).&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;It occured to me that DBC could be formalised by extending interfaces into Contracts.&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;About Design by Contract&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;In simple terms:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;The Supplier expects input data to meet certain conditions - "&lt;a href="http://en.wikipedia.org/wiki/Precondition"&gt;pre-conditions&lt;/a&gt;"&lt;/li&gt;&lt;li&gt;The Client expects the Supplier to behave in certain way - if the Supplier changes or stores data as well as returning output data it is harder to predict what will happen.&lt;/li&gt;&lt;li&gt;The Client expects output data to meet certain conditions - "&lt;a href="http://en.wikipedia.org/wiki/Postcondition"&gt;post-conditions&lt;/a&gt;"&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;strong&gt;Pre-conditions -&lt;/strong&gt; the Supplier is responsible for checking pre-conditions&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Behaviour &lt;/strong&gt;- if the Supplier code does not alter the state of the system but instead just returns data to the client then the Supplier's code is said to be &lt;a href="http://en.wikipedia.org/wiki/Side_effect_%28computer_science%29"&gt;Side-Effect free&lt;/a&gt; - Functional Programming techniques attempt to minimise Side Effects and &lt;a href="http://en.wikipedia.org/wiki/Imperative_programming"&gt;Imperative&lt;/a&gt; &lt;a href="http://en.wikipedia.org/wiki/Object-oriented_programming"&gt;Object Orientated &lt;/a&gt;techniques attempt to &lt;a href="http://en.wikipedia.org/wiki/Information_hiding"&gt;Encapsulate&lt;/a&gt; them within a manageable number of lines of code. Behaviour is usually tested by injecting &lt;a href="http://en.wikipedia.org/wiki/Mock_Object"&gt;Mock Object's&lt;/a&gt; as input data into the Supplier.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Post-Conditions -&lt;/strong&gt; Client test code is used to create &lt;a href="http://en.wikipedia.org/wiki/Assertion_(computing)"&gt;Assertions&lt;/a&gt; about the Supplier's code. Test Framework's allow us to create &lt;a href="http://en.wikipedia.org/wiki/Unit_testing"&gt;Unit Tests&lt;/a&gt; that test different Post-Conditions.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;How to extend Object Orientated (OO) Frameworks to support DBC. &lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Many OO frameworks such as .Net and Java leave it primarily upto the developer to use DBC techniques. As an example in C# a Pre-Condition might be:&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;if (inputParameter == null)&lt;br /&gt;{&lt;br /&gt;throw new ArgumentNullException("inputParemter");&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;This code simply checks an input parameter to ensure it is not a null reference and throws an exception if it is.&lt;/p&gt;&lt;p&gt;.Net does have an extension called &lt;a href="http://research.microsoft.com/specsharp/"&gt;Spec#&lt;/a&gt; that adds DBC functionality. Now I don't claim to be an expert on Spec# or any other specific DBC framework, however, it seems to me that DBC would be better implemented by "upgrading" interfaces into Contracts rather than decorating Classes with contract information. &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Why extend interfaces to support DBC?&lt;/strong&gt;&lt;/p&gt;&lt;ol&gt;&lt;li&gt;An interface by its nature has public methods, properties etc - it is public and therefore requires a contract&lt;/li&gt;&lt;li&gt;An interface can then have any number of concrete implementations, which all meet the pre and post conditions&lt;/li&gt;&lt;li&gt;An interface can then be a single port of call for all contractual information - function declarations, pre-conditions, post-conditions and exception types&lt;/li&gt;&lt;li&gt;This would negate the need for verbose commenting of functions and reduce the need for a throws keyword in Java&lt;/li&gt;&lt;li&gt;It would reduce the clutter in classes&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;An Example:&lt;/p&gt;&lt;p&gt;An interface IPerson, which has a single property Name, which cannot be null might look like:&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;contract CPerson&lt;br /&gt;{&lt;br /&gt;[PreCondition: NotNull(Name)]&lt;br /&gt;string Name&lt;br /&gt;{&lt;br /&gt;get;&lt;br /&gt;set;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;A concrete class would then "agree to"/"support" a contract, including any Pre-conditions and Post-conditions etc. &lt;p&gt;&lt;em&gt;&lt;strong&gt;Any thoughts on this idea are more than welcome!&lt;/strong&gt;&lt;/em&gt; &lt;p&gt;  &lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;Posting by Mark A Grant&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9009200-116750446956010952?l=markagrant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markagrant.blogspot.com/feeds/116750446956010952/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9009200&amp;postID=116750446956010952' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/116750446956010952'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/116750446956010952'/><link rel='alternate' type='text/html' href='http://markagrant.blogspot.com/2006/12/contracts-in-object-orientated-code.html' title='Contracts in Object Orientated Code'/><author><name>MAG</name><uri>http://www.blogger.com/profile/04468576656657088957</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-9009200.post-116734185119098883</id><published>2006-12-28T21:08:00.000Z</published><updated>2006-12-28T21:37:31.220Z</updated><title type='text'>Top 5 free .Net tools</title><content type='html'>On a daily basis I use some or all of the following tools for .Net development:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;strong&gt;.Net Framework -&lt;/strong&gt; it is perfectly possible to develop .Net applications without Visual Studio, this can be done by downloading the &lt;a href="http://msdn2.microsoft.com/en-us/netframework/aa731542.aspx"&gt;.Net Framework Software Development Kit&lt;/a&gt; and using your preferred &lt;a href="http://uk.builder.com/0,39026540,39242681,00.htm"&gt;Integrated Development Environment&lt;/a&gt; - Eclipse would be a good choice.&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.gotdotnet.com/Team/FxCop/"&gt;&lt;strong&gt;FxCop&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt; &lt;/strong&gt;- an automated rules-based code auditing tool that audits your compiled code. Checks include: naming conventions, multilingual support, null reference checks for public methods and functions, to name a few. Rules can be turned off and on and new rules created.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.aisto.com/roeder/dotnet/"&gt;.Net Reflector&lt;/a&gt; -&lt;/strong&gt; uses reflection to reverse engineer .Net assemblies into managed code (c# or VB.Net). It can also decompile the .Net framework core libraries, which is invaluable way of both understanding the logic behind certain functions or improving your coding techniques (mind you there are times when you would like to rewrite some of the code :-)&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.nunit.org/"&gt;&lt;strong&gt;NUnit&lt;/strong&gt;&lt;/a&gt; - a port of the popular Java equivalent JUnit.  A fast way to undertake Test Driven Development, especially with the next piece of software.&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.testdriven.net/"&gt;&lt;strong&gt;Test Driven .Net&lt;/strong&gt;&lt;/a&gt; - an inspired piece of software that allows developers to run NUnit test cases from within Visual Studio. Literally right clicking a test case (and selecting Run test) to run a test or a test class to run a whole suite of tests! Cool! &lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Some other free tools I haven't used, but would love to get some feedback on are: &lt;a href="http://nant.sourceforge.net/"&gt;NAnt &lt;/a&gt;(build manager), &lt;a href="http://ndoc.sourceforge.net/"&gt;NDoc&lt;/a&gt; (C# automated documentation), &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=86ce6052-d7f4-4aeb-9b7a-94635beebdda&amp;displaylang=en"&gt;CLR Profiler&lt;/a&gt; (performance profiles).&lt;/p&gt;&lt;p&gt;Also of interest may be the &lt;a href="http://www.mono-project.com/Main_Page"&gt;Mono Project&lt;/a&gt; that is a Linux/Solaris/Mac OS X/Windows/Unix implementation of the Common Language Runtime (CLR). This allows .Net applications to run on non-Microsoft platforms.&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;Posting by Mark A Grant&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9009200-116734185119098883?l=markagrant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markagrant.blogspot.com/feeds/116734185119098883/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9009200&amp;postID=116734185119098883' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/116734185119098883'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/116734185119098883'/><link rel='alternate' type='text/html' href='http://markagrant.blogspot.com/2006/12/top-5-free-net-tools.html' title='Top 5 free .Net tools'/><author><name>MAG</name><uri>http://www.blogger.com/profile/04468576656657088957</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-9009200.post-116733967041264715</id><published>2006-12-28T20:08:00.000Z</published><updated>2006-12-28T21:01:10.486Z</updated><title type='text'>Book Review: C# Cookbook by O'Reilly</title><content type='html'>&lt;a href="http://www.oreilly.com/catalog/csharpckbk2/"&gt;C# Cookbook&lt;/a&gt; is well worth &lt;a href="http://www.amazon.co.uk/Cookbook-Cookbooks-OReilly-Steve-Teilhet/dp/0596100639/sr=1-2/qid=1167339434/ref=sr_1_2/202-4914929-7548656?ie=UTF8&amp;s=books"&gt;purchasing&lt;/a&gt; and is aimed at moderate to advanced level C# developers.  It gives good coverage of all the major system libraries and programming techniques and includes "recipies" on all the advanced .Net 2.0 functionality.&lt;br /&gt;&lt;br /&gt;I typically end up purchasing 3 types of book on any new language I am learning. These include:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Simple Practical Introductions -&lt;/strong&gt; step-by-step guides that have plenty of examples and cover both the programming language and the development environment (I have managed to skip buying these recently in favour of internet tutorials)&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Reference Books -&lt;/strong&gt; these cover all the core libraries associated with a language including all classes and their public interfaces&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Advanced Guides -&lt;/strong&gt; specialist topics covered completely and in depth&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;C# Cookbook does not fall neatly into any of these categories. The Cookbook is about as close as any book to being a single source for C#. This is because it gives loads of practical examples (which are well written and not hacks), covers all the major areas and solves advanced problems. You need look no further to delve deeply into threading, generics, anonymous functions, collections and xml. Happy reading!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;Posting by Mark A Grant&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9009200-116733967041264715?l=markagrant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markagrant.blogspot.com/feeds/116733967041264715/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9009200&amp;postID=116733967041264715' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/116733967041264715'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/116733967041264715'/><link rel='alternate' type='text/html' href='http://markagrant.blogspot.com/2006/12/book-review-c-cookbook-by-oreilly.html' title='Book Review: C# Cookbook by O&apos;Reilly'/><author><name>MAG</name><uri>http://www.blogger.com/profile/04468576656657088957</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-9009200.post-116684889954021965</id><published>2006-12-23T04:02:00.000Z</published><updated>2006-12-23T04:47:25.150Z</updated><title type='text'>Installer Driven Development (tm)</title><content type='html'>Ever been in a software development project with limited specification, tight deadlines, grief, pain, and suffering -- a flying albatross that just won't die. Your cure may just be Installer Driven Development (IDD). The concept is simple: focus on your installer package first and your code second. If this sounds entirely insane and counter intuitive then read on (especially if you've worked on software projects that suck).&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;A typical project scenario - a la Dilbert.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Day 1:&lt;/strong&gt; Senior Exec has great idea for making money by selling a new software product to customers&lt;br /&gt;&lt;strong&gt;Day 2:&lt;/strong&gt; Senior Exec speaks to a few Senior Exec's he knows working at Customer sites who say they think its great (this is undocumented, unquantified, unqualified and turns into a solid business case by &lt;strong&gt;"the Power of Management"&lt;/strong&gt;)&lt;br /&gt;&lt;strong&gt;Day 3:&lt;/strong&gt; Senior Exec tells Middle Manager that customers are demanding Product X the solution to all their problems and that they need it by Y, and by the way this is vital to the company and he could gete promoted yadda, yadda&lt;br /&gt;&lt;strong&gt;Day 4:&lt;/strong&gt; Middle Manager has meeting with Tech team who say, "sure we're great we can deliver X by Y" and so that albatross starts its run up....&lt;br /&gt;&lt;br /&gt;Now, days 1 to 3 cannot easily be altered as they are outside your control, but day 4 can.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Revised Day 4:&lt;/strong&gt; Middle Manager has meeting with Tech team who say, "we are going to use IDD to ensure that we involve the customer, get the specification 100% correct and can deliver a demo that we can install on customer's machines for them to beta in time Z."&lt;br /&gt;&lt;br /&gt;This has just saved Middle Manager's arse and he runs off excited to tell Senior Exec.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;What do you do next - IDD? &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;1. Get a good installer program (&lt;a href="http://www.macrovision.com"&gt;Macrovision&lt;/a&gt; will do).&lt;br /&gt;&lt;br /&gt;2. For you to install your demo you will need to know exactly what types of machine the customer uses, what browser, whether their IT department would install it, security, what other software they use etc. Get the Sales team to find out who the customers are and as many other important requirements as possible, point the Sales team at the Marketing team for all Sales "Collateral" add the tasks to the bug tracking system with weekly email reminders.&lt;br /&gt;&lt;br /&gt;3. For your installer to look good you will require logos, help documents, links to websites, flash animations and a community website for your Beta customers etc. Get the Marketing team going, point them at the Sales team for all the customer profiles, feedback etc and add the tasks to the Bug tracking system with weekly email reminders.&lt;br /&gt;&lt;br /&gt;4. You need to know how many versions of the installer are required (for the Lite version of the software, the Enterprise version etc). Get the Legal department to start producing the license agreement and software contracts, point them in the direction of Middle Manager for all pricing, product roadmap etc, add the tasks to the Bug tracking system with weekly email reminders.&lt;br /&gt;&lt;br /&gt;5. Now you can either:&lt;br /&gt;&lt;br /&gt; a) Sit back and enjoy the bun fight and write some code or&lt;br /&gt;b) gather as much information from the different departments as possible, undertake all deployment testing and write a minimal Demo program that will be installed successfully from day 1.&lt;br /&gt;&lt;br /&gt;6. Finally, ensure you provide regular progress reports to Middle Manager, highlighting the outstanding issues in the Bug tracking system for Sales, Marketing and Legal departments and point out that they have been given weekly reminders of their tasks.&lt;br /&gt;&lt;br /&gt;Enjoy!&lt;div class="blogger-post-footer"&gt;Posting by Mark A Grant&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9009200-116684889954021965?l=markagrant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markagrant.blogspot.com/feeds/116684889954021965/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9009200&amp;postID=116684889954021965' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/116684889954021965'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/116684889954021965'/><link rel='alternate' type='text/html' href='http://markagrant.blogspot.com/2006/12/installer-driven-development-tm.html' title='Installer Driven Development (tm)'/><author><name>MAG</name><uri>http://www.blogger.com/profile/04468576656657088957</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-9009200.post-116682678422913652</id><published>2006-12-22T21:56:00.000Z</published><updated>2006-12-22T22:46:04.836Z</updated><title type='text'>Visual Studio Templates and Code Snippets are great, but ...</title><content type='html'>Anyone who has developed any Object Orientated code has re-written the same code patterns many times including creating a class (with comments), implementing getters and setters (or properties in .Net) and creating constructors. This is where templates and code snippets come to the rescue.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/6db0hwky(VS.80).aspx"&gt;Visual Studio (Item and Project) Templates&lt;/a&gt; -&lt;/strong&gt; when you create a new code file in Visual Studio you select from one of many default templates such as a Class, Interface or even a Windows Service. These then use code generation to fill in the blanks (such as a class name) and create your code for you. VS 2005 allows users to create their own custom templates, which is Great! I already have a class template, interface template and exception template customised with default comments, namespaces etc (actually the exception class is entirely generated for me). This is already saving time for myself and my team. Next up a Test Case template.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/ms165392(VS.80).aspx"&gt;Visual Studio Snippets&lt;/a&gt; -&lt;/strong&gt; these allow you to insert chunks of code into your file and then fill in the blanks, sort of like code-by-numbers. This is also great and I have created a code snippet for a property that cannot be initialised to null (I use this regularly as it is good design-by-contract programming). See example:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;private $type$ $field$;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;public $type$ $property$ &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;get&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;return $field$;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;set&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;if (value == null)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;throw new ArgumentNullException("value");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;$field$ = value;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;} &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Microsoft lovingly wraps a whole load of metadata around my code snippet in xml (the code is embedded into an xml CDATA section). This is also great and saves me time re-writing the same code.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;And now for the 'but'... ...BUT&lt;/strong&gt; this is entirely symptomatic of a broken programming paradigm. And in English - Object Orientated languages such as Java, .Net and C++ are flawed, as is the concept of Code Snippets and Templates.&lt;br /&gt;&lt;br /&gt;The simplified logic as a Powerpoint bullet argument (hey, its late and I'm getting tired):&lt;br /&gt;&lt;ol&gt;&lt;li&gt;In a good programming language we would only need to write the property code &lt;strong&gt;ONCE, &lt;/strong&gt;this point will not be explained as it is self-evident&lt;/li&gt;&lt;li&gt;We would therefore NOT need to insert and customize the same chunks of code in multiple locations&lt;/li&gt;&lt;li&gt;Which means Code Generation and therefore Templates and Code Snippets are redundant!!!&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Templates and Snippets suffer from the code generation problem that once created, if the snippet or template are changed the code is NOT. This means that the programmer must then go through all their code manually finding and replacing the generated code.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;A thought experiment -&lt;/strong&gt; what if we were to utilise code generation NOT when we insert the Snippet into our class file, but when we compile the code and then refer to the Snippet instead. Hmmm, well this would be an improvement in that we would then only write our Snippet once, and wouldn't have to manually update any changes. Our new code could look like:&lt;/p&gt;&lt;p&gt;Snippet Property (type = String, field = myString, Property = MyString);&lt;/p&gt;&lt;p&gt;Or something along these lines. :-) The Snippet of code is now effectively a "Template" for a Property. And why not take it a little further, lets make everything a Snippet and make it so that Snippets can include Snippets and the compiler will generate all our code from Snippets. Oh S***, what about the metadata, that's in XML and our Snippets are in C#, how would we generate those, and hey, haven't we just changed our language into some new Snippet language. &lt;/p&gt;&lt;p&gt;&lt;strong&gt;The problem with Code Generation -&lt;/strong&gt; is that we end up creating meta-languages (which is fine) that have a new syntax etc, because the language that the code is turned into is inadequate. A number of code generation frameworks use XML to store the customisable fields and XSLT to then generate the code (into C# or Java or whatever). Makes you wonder really, so what are the options: &lt;/p&gt;&lt;ol&gt;&lt;li&gt;Include a decent templating concept into the core language: &lt;a href="http://jura.sourceforge.net/"&gt;Jura&lt;/a&gt; is an example&lt;/li&gt;&lt;li&gt;Use &lt;a href="http://en.wikipedia.org/wiki/Functional_programming"&gt;functional programming&lt;/a&gt; - C# is starting to do this, but the starting blocks of classes and properties and interfaces are hard to then abstract out.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;And while i'm at it: any programming paradigm (Object Orientated programming) that requires design patterns is flawed. Mind you my hat goes off to the people who have managed to turn the &lt;a href="http://www.dofactory.com/Patterns/Patterns.aspx"&gt;design patterns into libraries&lt;/a&gt; using advanced OO techniques such as generics, reflection and code generation (there is a point to some of these techniques)!!!&lt;/p&gt;&lt;p&gt;To round up, code generation, templates, snippets and design patterns are all good concepts starting from a flawed language, namely an Object Orientated language.&lt;/p&gt;&lt;p&gt;Rant over :-)&lt;/p&gt;&lt;p&gt;P.S. just found this &lt;a href="http://www.codegeneration.net/"&gt;conference&lt;/a&gt; on Code Generation down the road from me - I might well attend!&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;Posting by Mark A Grant&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9009200-116682678422913652?l=markagrant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markagrant.blogspot.com/feeds/116682678422913652/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9009200&amp;postID=116682678422913652' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/116682678422913652'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/116682678422913652'/><link rel='alternate' type='text/html' href='http://markagrant.blogspot.com/2006/12/visual-studio-templates-and-code.html' title='Visual Studio Templates and Code Snippets are great, but ...'/><author><name>MAG</name><uri>http://www.blogger.com/profile/04468576656657088957</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-9009200.post-116578150659320785</id><published>2006-12-10T19:38:00.000Z</published><updated>2006-12-10T20:11:46.646Z</updated><title type='text'>What is programming?</title><content type='html'>A slightly philosophical title, which will no doubt end up with a lot of introspection, reflection and sole-searching (no really, looking at the bottom of our shoes and trying to extract meaning from a piece of chewing gum). Why ask the question? A little thought skittered across my brain and went something like this: "Does writing a function in an Excel spreadsheet consitute programming?"&lt;br /&gt;&lt;br /&gt;This thought was closely followed by a number of other thoughts, such as, is writing HTML programming? what about if we use a tool such as Dreamweaver? Hey, even more bizarre - can the creation of a Word document be called programming? I mean after all in Office 2003/2007 saving the file creates XML, and so does Dreamweaver. Let's face it this is clearly absurd, right?&lt;br /&gt;&lt;br /&gt;Ok, lets separate the tools we use, the output data we create and our thought process.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Does the tool maketh the programmer?&lt;/strong&gt; - Nope, this should be obvious, as even a monkey could use some of the Visual tools out there and still have no idea what they are doing.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Does doing maths make you a Mathematician? &lt;/strong&gt;- Nope again, although we may generate sums and equations it certainly doesn't mean we could qualify ourselves as numerate. But, just maybe this does mean we need to introduce a sliding scale of programming ability, the idea of programmerness or how much of a programmer are you? Let's face it Excel provides many levels of abstraction that allow you to use the sum function on a column of numbers in the same way Java abstracts away from assembly.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Our thought process -&lt;/strong&gt; so maybe it is purely our ability to comprehend a problem and provide a software based solution that differentiates us as programmers.&lt;br /&gt;&lt;br /&gt;In the end, this means that we as programmers can argue as much as we like about the merits of language X over language Y, but using a particular language does not imply that we are better than the complete dorks programming in Perl, which is disgustingly horrible to read and only a no-brainer would even try :-) Moving on, maybe, just maybe, we should be striving, nay, moving mountains to provide the best software we can by understanding the many different ideas in different languages.&lt;br /&gt;&lt;br /&gt;And, a note from my wife, who avoids anything technical like the plague - &lt;em&gt;&lt;strong&gt;there's an art to it!&lt;/strong&gt;&lt;/em&gt;&lt;div class="blogger-post-footer"&gt;Posting by Mark A Grant&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9009200-116578150659320785?l=markagrant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markagrant.blogspot.com/feeds/116578150659320785/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9009200&amp;postID=116578150659320785' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/116578150659320785'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/116578150659320785'/><link rel='alternate' type='text/html' href='http://markagrant.blogspot.com/2006/12/what-is-programming.html' title='What is programming?'/><author><name>MAG</name><uri>http://www.blogger.com/profile/04468576656657088957</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-9009200.post-116510102458594048</id><published>2006-12-02T22:10:00.000Z</published><updated>2006-12-02T23:10:24.703Z</updated><title type='text'>Bugbears</title><content type='html'>Nothing gets me (or anyone else I have worked with) more wound up than unhelpful error messages, or even worse error codes! For that matter I get wound up (because I think I can do better) with any error messages at all. Here's the rational, using a day to day example:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;RESTAURANT SCENARIO - &lt;/strong&gt;You walk into a restaurant and site down. The waiter appears and says, "What would you like to order, sir?" To which you respond, "I would like the spaghetti bolognese, with extra parmesan and some garlic."  Here are some potential responses when the spaghetti has run out:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;strong&gt;No Response &lt;/strong&gt;- blank stare - a system crash when everything hangs&lt;/li&gt;&lt;li&gt;&lt;strong&gt;"No"&lt;/strong&gt; - the equivalent of an undecipherable error code, only a complete geek would NOT be offended, but instead look it up on the internet or a FAQ&lt;/li&gt;&lt;li&gt;&lt;strong&gt;"We have run out of spaghetti"&lt;/strong&gt; - a typical response found by most software, it tells you the problem in a rather terse manner that leaves you feeling frustrated&lt;/li&gt;&lt;li&gt;&lt;strong&gt;"I am very sorry sir, but we have run out of spaghetti"&lt;/strong&gt; - slightly better technique used by some websites, which leave you with a warmer feeling, but hell what do you do next?&lt;/li&gt;&lt;li&gt;&lt;strong&gt;"I am very sorry sir, but we have run out of spaghetti, perhaps you would like to try the lasagne, which is equally delicious."&lt;/strong&gt; - not only does this describe the problem but gives the customer an option (or two)&lt;/li&gt;&lt;li&gt;&lt;strong&gt;"I am very sorry sir, but we have run out of spaghetti, we have more arriving tomorrow, perhaps you would like to try the lasagne, which is equally delicious."&lt;/strong&gt; - not only does this describe the problem but gives the customer an option (or two) and shows the customer that the problem is being resolved&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Of these, responses 5 or 6 are best, but software typically uses 3 or 4 and sometimes 2 (1 is typically outside our control). I have created 6 potential responses, but many more can be generated when pondering the following questions:&lt;/p&gt;&lt;p&gt;Does the user know an error has occured? Does the user know what the error is? Does the user know why the error has occured? Is the response user friendly? Does the user know what options are available? Does the user know how the problem will be resolved? Who is expected to resolve the problem, the user or the software? How is the message communicated? And, Is the user happy with the outcome?&lt;/p&gt;&lt;p&gt;This is one hell of a lot of stuff to think about for a simple error, but without it users will get frustrated, angry and stressed. This is BAD!!!&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Simple Steps to reduce stress: &lt;/strong&gt;&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Use good coding practices/conventions to control errors/exceptional behaviour and validate input properly&lt;/li&gt;&lt;li&gt;Think about the a user's experience (be polite)&lt;/li&gt;&lt;li&gt;Give users options&lt;/li&gt;&lt;li&gt;Give users confidence that the error is a one-off (or very rare) and can be resolved&lt;/li&gt;&lt;li&gt;Resolve the error with as little disruption to the user as possible&lt;/li&gt;&lt;li&gt;gather feedback (in a non-intrusive way - you are now asking the user to do something when the software has died)&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;strong&gt;Some simple examples of where small changes make big differences.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.petrolprices.com"&gt;&lt;strong&gt;www.petrolprices.com&lt;/strong&gt;&lt;/a&gt; - in their forms they have textboxes that validate your entries immediately and put a bright green tick at the end. This saves unhelpful page refreshes where you then have to scan back through your web page to find the incorrect field entry.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Microsoft Feedback Gathering System -&lt;/strong&gt; its optional, but at least it empowers users so they thinnk they can do something (if only a little)&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Password reminder services -&lt;/strong&gt; how annoyed would you be if you forgot your password and there was no option to get a reminder email!&lt;/p&gt;&lt;p&gt;Anyhow, without going on forever, think about the user, resolve the problem with as little hassle to the user as is feasible and ensure it doesn't happen again - You Bad Boy!&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;Posting by Mark A Grant&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9009200-116510102458594048?l=markagrant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markagrant.blogspot.com/feeds/116510102458594048/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9009200&amp;postID=116510102458594048' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/116510102458594048'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/116510102458594048'/><link rel='alternate' type='text/html' href='http://markagrant.blogspot.com/2006/12/bugbears.html' title='Bugbears'/><author><name>MAG</name><uri>http://www.blogger.com/profile/04468576656657088957</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>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9009200.post-116502567517610804</id><published>2006-12-02T01:20:00.000Z</published><updated>2006-12-02T02:48:24.993Z</updated><title type='text'>Technology Time Warp</title><content type='html'>In the last few weeks I have had cause to try out &lt;a href="http://clisp.cons.org/"&gt;Lisp&lt;/a&gt; and &lt;a href="http://www.haskell.org/haskellwiki/Haskell"&gt;Haskell&lt;/a&gt;, both of which are pretty old technologies (although Lisp beats Haskell hands down being specified in &lt;a href="http://en.wikipedia.org/wiki/Lisp_programming_language"&gt;1958&lt;/a&gt; as opposed to &lt;a href="http://en.wikipedia.org/wiki/Haskell_programming_language"&gt;1990&lt;/a&gt;). I have come to some interesting conclusions (which surprised me, but will not surprise users to these languages). Firstly, that programming language progression is not linear and secondly that I had missed (but been using in XSLT) an important programming paradigm.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Why try Lisp and Haskell?&lt;/strong&gt; .Net 3.0 have some interesting new features, which step out from the purely Object Orientated view of the world and allow us to do some pretty cool stuff. These are namely Functional Programming (of which Lisp and Haskell are pure examples) and &lt;a href="http://msdn.microsoft.com/data/ref/linq/"&gt;LINQ&lt;/a&gt; which provide relational query, set and transformation programming. Anyone who has used a relational database will instantly grasp LINQ, but what is Functional programming?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Functional Programming -&lt;/strong&gt; &lt;a href="http://en.wikipedia.org/wiki/Functional_programming"&gt;Wikipedia&lt;/a&gt; has a great description of FP, but in essence a FP function does not store any state information. You can therefore blackbox FP code and with the same set of inputs you will always get the same set of outputs. This has performance and maintainability benefits, as software can scale (see Google's &lt;a href="http://www.cs.vu.nl/~ralf/MapReduce/paper.pdf"&gt;MapReduce&lt;/a&gt; function) and will not have side effects (they are also thread safe).&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;Conclusion - Was it worth trying Lisp and Haskell -&lt;/strong&gt; in one word, yes. These languages provide great run-time interpreters/compilers and it took all of 3 minutes after download to start writing some pretty cool programs. Mind you trying to take in a new syntax (or two) with entirely different programming paradigms was pretty hard, but the upshot is a new way of thinking about coding especially for those of us brought up on &lt;a href="http://en.wikipedia.org/wiki/Imperative_programming"&gt;Imperative&lt;/a&gt; Object Orientated code.&lt;br /&gt;&lt;br /&gt;Some cool references:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.paulgraham.com/icad.html"&gt;Paul Graham on Lisp&lt;/a&gt; - a bit of a Lisp zealot, but is a great blog&lt;/li&gt;&lt;li&gt;&lt;a href="http://ryan-technorabble.blogspot.com/2006/08/functional-programming-in-java-c-vbnet.html"&gt;Technorabble&lt;/a&gt; - this guy got here before me!!!&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;Posting by Mark A Grant&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9009200-116502567517610804?l=markagrant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markagrant.blogspot.com/feeds/116502567517610804/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9009200&amp;postID=116502567517610804' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/116502567517610804'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/116502567517610804'/><link rel='alternate' type='text/html' href='http://markagrant.blogspot.com/2006/12/technology-time-warp.html' title='Technology Time Warp'/><author><name>MAG</name><uri>http://www.blogger.com/profile/04468576656657088957</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-9009200.post-109958884876760026</id><published>2004-11-04T17:19:00.000Z</published><updated>2006-11-23T23:12:22.580Z</updated><title type='text'>Post Zero</title><content type='html'>My zeroth post on software development, business and programming concepts (a broad range, but should cover all need to know topics for people in IT!) . After 10 years in IT and start-up companies I finally feel like I might have some things to say about getting software off the ground and paid for by customers. In a nutshell its hard, extremely hard!&lt;br /&gt;&lt;br /&gt;Wow there cowboy, lets qualify that last comment, rank it, digest it and put it in perspective. Ok, is it harder than a degree from Cambridge University in Engineering, for want of a better example? Or maybe, job interviews? Or presentations? Or say competing in the Olympics?&lt;br /&gt;&lt;br /&gt;Ok, so academically it is probably easier than a Cambridge Degree, interviews and presentations are a walk in the park, and the Olympics is likely to be more physically demanding (let's face it typing really does only tax a few minor muscle groups), but ...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;... it takes the dedication of an international athelete, the business and technical smarts of a Bill Gates and the tough sales driven attitude of Steve Ballmer to get the business off the floor and making money.&lt;br /&gt;&lt;br /&gt;But how do I go soooopeeeer nova like Chad and Stev (Youtube founders) or Larry and Sergey (Google founders)? I've no idea, please refer to one of their biographies for inspiration, or alternatively I'll sell you one.&lt;br /&gt;&lt;br /&gt;STOP, of course I have an idea, given that Youtube sold to Google, you need to create a company, raise loads of money, get loads of people using your software and sell it to Youtube, thus extending the chain and increasing Google's e-domination. So, an automated tool to generate good content :-0&lt;br /&gt;&lt;br /&gt;What remains to say? Well, maybe a few hints and tips, some juicy reviews of the current state-of-the-art-or-is-it-a-science and some anecdotes taken from the front line. Bye for now, Mark&lt;br /&gt;&lt;br /&gt;P.S. To blogger, please can you update your software to update my date when I update my post.&lt;br /&gt;&lt;br /&gt;P.P.S Published 23rd November 2006&lt;div class="blogger-post-footer"&gt;Posting by Mark A Grant&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9009200-109958884876760026?l=markagrant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markagrant.blogspot.com/feeds/109958884876760026/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9009200&amp;postID=109958884876760026' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/109958884876760026'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9009200/posts/default/109958884876760026'/><link rel='alternate' type='text/html' href='http://markagrant.blogspot.com/2004/11/post-zero.html' title='Post Zero'/><author><name>MAG</name><uri>http://www.blogger.com/profile/04468576656657088957</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>
