- RT @bryonfinke: The vast majority of your 'friends' and acquaintances would rather see you fail. Get over it. Use it as motivation. # ... 4 hours ago
- RT @GeorgeTakei: In Arkansas to narrate the symphony, stopped by Rohwer Camp, where I spend much of my childhood interned. A pic: http: ... 6 hours ago
- I'm attending a Meetup with Seattle Software Craftsmanship Community http://t.co/BcRHhGi3 7 hours ago
- RT @BorowitzReport: Now that we all agree contraception is a bad idea, let's take a harder look at electricity and soap. #cnndebate 20 hours ago
- Doing BEARD estimation on next release cycles MMFs http://t.co/96YaRUbY 1 day ago
I Am Not Myself
Bills.Pay(Developer.Skills).ShouldBeTrue()
Sinister Bug is Sinister
Posted by on January 24, 2012
Can you spot the bug in this flags enumeration?
[Flags]
public enum ItemCoreChangeType
{
ViewStyleChanged = 1,
VaryByStructureChanged = 2,
LayersChanged = 4,
LayerContentsChanged = 8,
PropertiesChanged = 16,
ErrorsChanged = 32,
ChangeHistoryCleared = 64,
EditableCommentChanged = 128,
NeedsValidation = 256,
AffectsPropertyChangeHistory = 512,
AffectsLayerChangeHistory = 1024,
PushFormatters = 2048,
ResetValueGroups = 4096,
SkipChangeTrackingUpdate = 8092,
StatusChanged = 16384,
Flexible2DIndicesChanged = 32768,
}
In case you can’t spot it with the naked eye (I couldn’t, coworker Alex caught it.), watch this video. Pay attention to the binary display as I enter in the values of my enumeration above. Notice how the bit is steadily walking down the display? What happens when I hit SkipChangeTrackingUpdate?
So it seems that when I use the SkipChangeTrackingUpdate value I am actually sending many of the other values in this flags enumeration. Nasty bug to track down eh?
What makes this bug so sinister is just how long it took to find. Using the blame command in git, I see the following result. The names have been changed to protect the guilty.
72fe38b4 (dirk.diggler 2010-02-10 23:49:28 -0800 33) SkipChangeTrackingUpdate = 8092,
So this particular flaw has been in the code base unnoticed for close to two years. Two years worth of code has been written with the assumption that SkipChangeTrackingUpdate actually sends the value of 9 different flag values. Fixing the flag value could potentially effect any part of that code.
What do?
Lucky for me, a search for that flag in the entire code base returned 3 usages, one of which was the definition of the flag, one was the usage of the flag and one consuming the flag.
Crisis averted but it could have been much worse.
SSDNUG Presents: James Thigpen – Moar Cats Please: Software Development at Cheezburger
Posted by on January 18, 2012
The South Sound .NET Users group is proud to present James Thigpen on Thursday Feburary 9th at 7:00PM at the Olympia Center in the heart of downtown Olympia, WA.
There is a lot of talk in an abstract sense about how agile software practices work. James is going to talk about how Cheezburger does agile with a remote team spread across the US and Europe. This isn’t theory, this is how Cheezburger ships code every day. Expect to hear what has worked and what failed.
Cheezburger is heavily invested in TDD, Continuous Deployment, Automated Testing, Split Testing, agile/lean methodologies, and continuous improvement. They have doubled the size of their team in the past year and lived to tell the tale. Cheezburger usually ships code more than ten times a day without interrupting the 1.8 million daily active users visiting their sites and they have a lot of fun doing it.
James Thigpen is the Director of Engineering at Cheezburger Network, one of the largest online humor companies in the world. James has a deep passion for agile and lean software development practices. He has a wide variety of experience developing software and leading teams in industries such as municipal inventory, biomedical imaging, IT management, and online media.
If you missed the January meeting with Adron Hall, you can still catch it online.
Displaying a Map of the Current Location with MonoTouch
Posted by on January 17, 2012
Today, I started spiking on displaying maps in iOS using MonoTouch. I wanted to discover the minimum amount of code needed to get the users current location via the iOS GPS services and then display that location on the a map.
To get the devices current location you need an instance of CLLocationManager found in the MonoTouch.CoreLocation namespace. The location manager accesses the actual hardware on the device and can be a real power drain, so you want to use it as little as possible.
using System;
using MonoTouch.CoreLocation;
namespace App.UI
{
public class LocationService
{
private CLLocationManager locationManager;
public LocationService()
{
locationManager = new CLLocationManager();
}
public CLLocationCoordinate2D GetCurrentLocation()
{
//dirty for now just to get some info.
locationManager.StartUpdatingLocation();
while(locationManager.Location == null);
locationManager.StopUpdatingLocation();
return locationManager.Location.Coordinate;
}
}
}
This simple service shows the absolute minimum needed to retrieve the devices current location. First, we tell the manager to StartUpdatingLocation which will trigger a dialog to the user requesting access to the devices location services. The current location is then available from the Location property. It takes a few seconds to populate though, which is why most of the demo code you will find uses a LocationDelegate to consume the data. I wanted something a little simpler because I don’t actually need updates to the location, so I spin until the Location property is not null. I then grab the Coordinate from the Location property and tell the manager to StopUpdatingLocation.
On a side note the user can disable location globally on the device. You can check to see if the user has done so via the static member LocationServicesEnabled. You could use this to display a dialog to ask the user to put in a zip code maybe as an alternative.
To display the location on a map for the user you will need to use the MKMapView from the MonoTouch.MapKit namespace. I have chosen to create a MapViewController class that extends UIViewController to wrap all this code in.
using System;
using System.Drawing;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.MapKit;
using MonoTouch.CoreLocation;
namespace App.UI
{
public class MapViewController : UIViewController
{
private LocationService locationService;
private MKMapView mapView;
public ProductsViewController(LocationService locationService)
{
this.locationService = locationService;
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
var currentLocation = locationService.GetCurrentLocation();
var visibleRegion = BuildVisibleRegion(currentLocation);
mapView = BuildMapView(true);
mapView.SetRegion(visibleRegion, true);
this.View.AddSubview(mapView);
}
private MKMapView BuildMapView(bool showUserLocation)
{
var view = new MKMapView()
{
ShowsUserLocation = showUserLocation
};
view.SizeToFit();
view.Frame = new RectangleF(0, 0, this.View.Frame.Width, this.View.Frame.Height);
return view;
}
private MKCoordinateRegion BuildVisibleRegion(CLLocationCoordinate2D currentLocation)
{
var span = new MKCoordinateSpan(0.2,0.2);
var region = new MKCoordinateRegion(currentLocation,span);
return region;
}
}
}
This simple ViewController overrides the ViewDidLoad method, consumes the LocationService to get the current location and then displays that location on with a MKMapView. We build up the map view in two steps, the first creates the instance of the map view and sizes it to fit the viewable area of the given display. The MKMapView has a property that will automatically show an indicator of where the curent location is, setting this property is all you need to do to display the map and location. There is a catch though, if you were to display this map now you would see a map of the entire United States and not a reasonable local view of the area. The second step is what zooms the map into a reasonable region to display.
If we display this controller now in the iPhone Simulator, this is what we see.
Getting Started Building iOS Applications with MonoTouch
Posted by on January 16, 2012
I have been flirting with the idea of getting into mobile development in my spare time. I have went so far as to offer myself out as a developer to startups in Chicago to develop simple iOS applications in exchange for tool licenses. I am a firm believer in the idea that a craftsman buys his own tools. I am not buying them with my own money here, but I certainly am with my effort.
I also wanted to turn this experience into a few blog posts that might help someone else who has chosen to go down the same path that I have.
So what does a .NET developer need to get started writing an iOS application? There are three things to consider here. The first being picking up Objective-C as a language, second is learning the iOS API and third is relearning how to do stuff we already know like consuming a JSON service. Put another way, we need to learn a language, a platform and the idiomatic way of doing things in this particular development culture. That is a lot to bite off in a short period of time and still be productive and getting stuff done.
For this reason, I chose to develop my first few applications using Xamarin’s MonoTouch. Taking this route allows me to leverage my current skills with C# and the .NET platform while learning the iOS API and still manage to be productive. I can noodle around with Objective-C at a later time.
The first thing you will notice about MonoTouch is the price, at $399 it is quite a leap of faith. But you can install and use the evaluation version to your hearts content. You only have to pony up money once you are ready to ship to the App Store.
To get up and running with MonoTouch, you will need to install the following things in this order:
- XCode 4 – If you don’t mind paying $5, you can get this from the Apple App Store.
- MonoDevelop – This is a completely free IDE for the Mono framework.
- MonoTouch Evaulation
You will also need a Mac. Yes sorry, thems the breaks.
To create an iOS application simply select File > New Project and dig down to the MonoTouch iPhone project template. There are also templates for iPad and Universal. Universal allows you to create a single application that will work on both the iPhone and the iPad. You can also create library assemblies just like you would expect in Visual Studio.
There is one catch though, MonoTouch project types are limited in the amount of the framework you will have access to work against and what 3rd party libraries you can reference. It is similar to working with Client Profile projects in Visual Studio. Everything you reference needs to target MonoTouch as well.
For instance, I have been working on an application that consumes a Xml-Rpc service. There is already a fairly awesome OSS library from Cook Computing for all your Xml-Rpc needs. You cannot simply download the dll and reference it in your project. The dll needs to be compiled as a MonoTouch assembly. And all code needs to conform to the limited framework profile of MonoTouch. Cook Computing’s library has both client and server components in one library. The server components depend on HttpResponse & HttpReqeust which are not available in a MonoTouch application.
I was able to solve this problem fairly easily by creating my own fork of the Cook Computing library and pulling in only the types needed for client communication. I even went so far as to publish this work on GitHub so others can simply use my fork and get back to making things awesome. Yay, OSS!
If you would like to look at a couple nontrivial applications written using MonoTouch to get an idea of where to start, the Washington State Department of Transportation has a great application published to the App Store now that is fully open source. I used this application as a guide post when creating my first MonoTouch app which you can find here.
This should be enough to get you on your way to writing your first application. I have some more tips around using OSS libraries and Unit Testing, but that will have to wait for another day in another blog post. Enjoy and happy non-conformist .NET application development day.
Adron Hall Visual Studio AWS Toolkit & SDK Presentation Video
Posted by on January 14, 2012
Overview
During this presentation I will provide an overview of what is needed to get started using Visual Studio 2010 with the AWS Toolkit & SDK. We’ll also cover the basic design ideas behind the do’s and don’ts of cloud architecture and development. There will be some hands on coding (if you’d like to bring a laptop to follow along) and we will deploy code (wireless/cat5 connection pending) into AWS Cloud Services & get EC2 instances up and running live!
About Adron
I’m a jovial, sometimes TDD (Test Driven Development), sometimes BDD (Behavior Driven Development), get things done well, software architect, engineer, code monkey, coder, or what have you. I run the gamut of development stacks between the .NET Framework & Microsoft Technologies but will admit my latest favorite is Ruby on Rails and .NET MVC work with a touch of Sinatra’s clean architecture covered with an awesome layer of Javascript for tasty perfection. I love what I do and commonly add a very business oriented, get the job done, agile (sometimes eXtreme Agile, sometimes whatever it takes), and entrepreneurial effort to my work. I also like to mentor (teach), write (re: blog, etc), and even work on projects in addition to work related things.
You can find more on his site.
Video
Slides
Source
The source for this presentation can be found on Adron’s github account.
Testing Rendered Output of NancyFx with the Razor View Engine Gotchas
Posted by on January 3, 2012
I have been working on a small sample application called SignMeUp. My intention is to practice concepts I am learning while reading Growing Object Oriented Software Guided by Tests. I am using the awesome NancyFx micro-framework my web delivery mechanism and Razor as my view engine.
To start I have the following unit test.
[TestFixture]
public class when_visiting_the_root_of_the_site : with_a_browser
{
private BrowserResponse response;
public override void Given()
{
Configure(with =>
{
with.Module<RootModule>();
with.Dependency<IEmailService>(Substitute.For<IEmailService>());
with.Dependency<DataContext>(TestDataContextFactory.Build());
});
base.Given();
}
public override void When()
{
response = subject.Get("/");
}
[Test]
public void it_should_be_successful()
{
response.StatusCode.ShouldBe(HttpStatusCode.OK);
}
[Test]
public void it_should_show_the_signup_form()
{
response.Body["form"].ShouldExistOnce()
.And.Attribute["action"].ShouldBe("/");
}
}
I have been beating my head against a problem for a few days (over the course of several 1-2 hour development sessions) that has been baffling me. This test compiles and executes and the first test returns successful. The second test has always failed because the Body collection was always empty. The truly enraging thing is I could fire up the site in IISExpress and see that it worked properly.
After searching the internet high and low, trolling source repositories of example apps and finally breaking down and scouring the NancyFx source I have discovered the root of my problem.
Gotcha #1: When executing end to end tests like this from a test library you need to makes sure that your test assembly has knowledge of your views. The simplest solution for this is to set all your views to “Copy if newer” in the properties dialog in visual studio. The default view location should work from here.
Gotcha #2: Your test assembly needs to reference Nancy.ViewEngines.Razor. If you do not have this reference, Nancy will happily process your request and simply return an empty body. No error, no warning, nothing.
Will Write iOS Application for Licenses
Posted by on December 30, 2011
I am interested in getting more into iOS development. I have written some prototypes with XCode and MonoTouch. I really like MonoTouch and would really like my own license, so I can create some personal applications and play in the space. But sadly am unable to afford it at the moment.
That is where you come in. If you would like a simple iOS application for your organization and are willing to fund the purchase price of an Apple Developers license and a MonoTouch license, I will develop an application for you and walk it through the Apple submission process to get it up on the App Store.
Here are some more details:
Apple Developers License: $99
MonoTouch Professional License: $399
Payment Method: PayPal
Example of what I can do with the MonoTouch trial.
This application consumes & displays rss & twitter feeds as well as showing some nice existing web content. This is the type of application I am offering to build for you.
Sound like a deal? Are you interested? Contact me.
Getting Gilded Rose Under Test
Posted by on December 22, 2011
While I was attending the Software Craftsmanship North America conference this year, Ian Davis post a video of himself performing the Gilded Rose Kata. I really enjoyed watching it and wanted to take a stab at it myself. I had a couple hours to kill sitting at O’Hair waiting on my flight so I fired up my environment and took a stab at it.
This video is the result of that session. The video consists of me getting the system under test. I did attempt a refactoring a couple times but kept driving to Ian’s solution because it was to fresh in my head. So I trimmed the solution out of my video and left only the testing. Go watch Ian’s video for a elegant solution to the problem. Do note that there is a signifigant amount of play and experimentation in this video, I am just dorking around.
It took me a while to post this because I originally recorded the session using Camtasia:Mac, which is a horribly broken piece of software. I had to wait until I could get a license for ScreenFlow before acutally producing the video. If you are in the market for software to do this kind of video, go with ScreenFlow.
If you are interested, I am using the Giles auto test runner, Nunit and several Resharper macros in the video. You can find my source on github.
Be sure to watch in HD it makes the text much more readable.
The Four Rules of Simple Design
Posted by on December 21, 2011
When you first get involved with agile development, you quickly hear about the SOLID principals and design patterns. They are a bit much to bite off at first. Through the Ruby community I have discovered a simpler more fundamental set of guidance for beginners that appear to be fundamentals for the higher level principals of SOLID, called the Four Rules of Simple Design:
- Pass all tests
- Clear, expressive & consistent
- Duplicates no behavior or configuration
- Minimal methods, classes & modules
Here is an amazing introduction to the concept by JB Rains.


The Day the LOLcats Died