Geeks With Blogs
Liam McLennan May 2010 Entries
Command Query Separation
Command query separation is a strategy, proposed by Bertrand Meyer, that each of an object’s methods should be either a command or a query. A command is an operation that changes the state of a system, and a query is an operation that returns a value. This is not the same thing as CQRS, hence why I think that CQRS is poorly named. An Example of Command Query Separation Consider a system that models books and shelves. There is a rule that a shelf may not be removed if it holds any books. One way to ......

Posted On Sunday, May 30, 2010 7:01 PM

mongoDB Management Studio
This weekend I have been in Sydney at the MS Web Camp, learning about web application development. At the end of the first day we came up with application ideas and pitched them. My idea was to build a web management application for mongoDB. mongoDB I pitched my idea, put down the microphone, and then someone asked, “what’s mongo?”. Good question. MongoDB is a document database that stores JSON style documents. This is a JSON document for a tweet from twitter: db.tweets.find()[0] { "_id" : ObjectId("4bfe4946cfbfb0142... ......

Posted On Saturday, May 29, 2010 2:53 AM

Unnamed Refactoring
This post is a message in a bottle. It cast it into the sea in the hope that it will one day return to me, stuffed to the cork with enlightenment. Yesterday I tweeted, what is the name of the pattern where you replace a multi-way conditional with an associative array? I said ‘pattern’ but I meant ‘refactoring’. Anyway, no one replied so I will describe the refactoring here. Programmers tend to think imperatively, which leads to code such as: public int GetPopulation(string country) { if (country ......

Posted On Thursday, May 27, 2010 3:18 AM

Pimp the Podcast

David Starr interviewed me for his pluralcast podcast. We talked about software craftsmanship and how to spread knowledge.

Posted On Tuesday, May 25, 2010 6:23 PM

Why’s Poignant Guide To Ruby
According to Wikipedia, “why the lucky stiff was the persona of an anonymous, but prolific writer, cartoonist, musician, artist, and computer programmer”. He looks a bit like Jack Black. His book, Why’s Poignant Guide to Ruby, is a classic, though it can be hard to find since Why disappeared. If you want to learn the Ruby programming language I highly recommend Why’s Poignant Guide to Ruby. I am including a link here so that others who search for it may find it more easily ......

Posted On Sunday, May 23, 2010 4:54 PM

My Latest Hare-Brained Scheme
I have not had a significant side project for a while but I have been working on a product idea. Its an analytics application that analyses twitter data and reports on market sentiment. The target market is companies who want to track trends in consumer sentiment. My idea is to teach the application to divide relevant tweets into ‘positive’ and ‘negative’ categories. If the input was the set of tweets featuring the word ‘telstra’ the application would find the following tweet: and put it in the ‘negative’ ......

Posted On Saturday, May 22, 2010 9:18 PM

NHibernate Error - Expression argument must be of type ICollection

The above error occurred when I executed a linq query using the following expression:

(s) => s.Book.Slug.Equals(bookslug) && ids.Contains(s.Id);

ids in this case is of type IEnumerable<Guid>. As indicated by the error message the fix is to change ids to ICollection<Guid>, then the query executes successfully.

Posted On Monday, May 17, 2010 8:20 PM

CoffeeScript Test Framework
Tonight the Brisbane Alt.NET group is doing a coding dojo. I am hoping to talk someone into pairing with me to solve the kata in CoffeeScript. CoffeeScript is an awesome language, half javascript, half ruby, that compiles to javascript. To assist with tonight’s dojo I wrote the following micro test framework for CoffeeScript: <html> <body> <div> <h2>Test Results:</h2> <p class='results' /> </div> <script src="http://ajax.googleapis... ......

Posted On Thursday, May 6, 2010 1:14 AM

Talking Shop With Richard Banks and Paul Batum
Last night Richard Banks recorded Paul Batum and I for his podcast. We talked about Alt.NET Seattle 2010 and my software craftsmanship tour. It was a lot of fun and I hope you enjoy it ......

Posted On Monday, May 3, 2010 7:19 PM

Copyright © Liam McLennan | Powered by: