Tuesday, May 03, 2011

Agile Austin May 3, 2011 - Steven “Doc” List: The Agile Lego Game

Steven "Doc" List of ThoughtWorks led the Agile group in a fun game of learning agile principles by playing with Legos. One member of each team volunteered to be the "customer", our team was fortunate enough to have Scott Killen. The customer provided each team with a set of user stories like 'your animal should have wings'. We walked through three iterations of estimating, planning, building, and retrospection. The game was a fun way to learn Agile and get to know other members better.











C#: Does a Close() automatically call a Flush()

The following C# code always looked a little clunky to me, because a Close() should probably perform a flush as well. I quickly Googled around and my suspicions were confirmed that the Close() method would automatically do a Flush().
Response.Write(qdbXml);
Response.Flush();
Response.Close();
So while cleaning up some other code I removed the Flush() call. Then everything stopped working. I thought it was the other changes I made at first. Chrome gave this helpful message:
Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data.
I restored the Flush() and everything worked great again. The Response object above is a System.Web.Mvc.Controller.Response object which doesn't necessarily work like some other stream objects and needs flushing before closing.
TIL not all stream objects behave alike and I can get in trouble by assuming hastily gathered Googled results apply to me.

Friday, April 22, 2011

SQL Server: Joining on NULLs

Today I learned you can't join tables on NULLs because SQL Server deems a NULL to be an ambiguous quantity so two NULLs are not the same NULL. You can force SQL Server to do the join by doing something like this
... colors c JOIN points p ON (c.color = p.color OR (c.color IS NULL AND p.color IS NULL))
This example assumes only one team will have a NULL color.
CREATE TABLE colors (
  team      varchar(16) NOT NULL,
  color     varchar(32) NULL,
)
CREATE TABLE points (
  color     varchar(32) NULL,
  points    int
)

INSERT INTO colors VALUES ('lobsters','red')
INSERT INTO colors VALUES ('swans','white')
INSERT INTO colors VALUES ('jellyfish',NULL)

INSERT INTO points VALUES ('red',100)
INSERT INTO points VALUES ('white',90)
INSERT INTO points VALUES (NULL,80)
SELECT * FROM colors c JOIN points p ON c.color = p.color
-- returns:
--lobsters         red                              red                              100
--swans            white                            white                            90
SELECT * FROM colors c JOIN points p ON (c.color = p.color OR (c.color IS NULL AND p.color IS NULL))
-- returns:
--lobsters         red                              red                              100
--swans            white                            white                            90
--jellyfish        NULL                             NULL                             80

Wednesday, March 30, 2011

Austin Java User's Group March 29th, Android and OSGi


We had a great meeting - it never hurts to start with free pizza.
Only five of the fifty two people attending were looking for jobs, and lots of jobs were being offered. Charles Schwab had a few dozen jobs available; HP and NetSpend also had positions to fill. Jeff Hennigan from KForce was also present - it's always a good sign to have recruiters come to the JUG.
Sam Griffin gave an excellent introduction to Android programming. He gave a demo on how to create and publish an app to a phone. Sam said it was very easy to access features like GPS, Speech Recognition, TextToSpeech, OpenGL for 2 and 3d graphics. Android also has SqlLite builtin.

Simon Chen talked about the basics of OSGi - which is a good thing since before the meeting I couldn't even spell OSGi. Simon described OSGi as a fancy classloader that manages components of a java application. It's like Service Oriented Architecture within an application; you call components embedded in bundles and you only have to load them once.



Thanks to Georgina Chen for the pictures.

Wednesday, March 23, 2011

How to prevent NUnit from running some tests on the build server

Certain NUnit tests you only want to run on your local machine and some you only want to run on the build server. To make this easy NUnit offers the "Category" attribute.
[Test][Category("DoNotRunOnBuildServer")]
public void ReadFromLocalWebServiceTest()
{
    var qdbBrandHttpReader = new QdbBrandHttpReader();
    string xml = qdbBrandHttpReader.ReadFromLocalWebService();
    ...
}
On your build server, when you invoke NUnit console add the option "/exclude:DoNotRunOnBuildServer", then it will not even try to run these tests.
Typically this is used with a category like "LongRunningTests" to prevent tests from running on your local box.

Monday, March 21, 2011

Where do good ideas come from?

Good RSA video. Reminds me that our tech culture needs more "coffee house" type meeting spaces.


Also see the TED Talk.

AutoMapper for C#

I finally got around to using AutoMapper from fellow Austinite Jimmy Bogard. I watched Jimmy's helpful video and the rest was easy.
AutoMapper is a Data Transfer Object (DTO) helper framework that can map your domain objects to view objects.
In my case I wanted to add extra formatting to render my domain objects as HTML, but realized a "ToHtml()" method on the domain object doesn't smell so good. I created a View Model directly from the domain model via Automapper (with only the attributes I needed to display) and added the HTML rendering code there.
Is that the smell of a pine forest after a Spring rain?

Pine Forest by ®DS
Pine Forest a photo by ®DS on Flickr.