Michael’s blog


Continuous Integration 101

Posted in Uncategorized by nelsonmichael on December 5, 2008

Since my workstation was down much of today (note to self, when saying “yes” to “do you want to schedule a chkdsk at next reboot… remember to reboot before going home, not at 9:30 the next morning!)  I used the time waiting for it to complete to install and configure Hudson

CI details are in the links below, but essentially Hudson polls SVN every minute to see if any new code has been checked in. If so, it gets the latest code and performs a build.

Normally it would also run the unit tests, FxCop and any other tasks you’d like to take care of to verify everything’s hunky dory but I haven’t had time to get all that working yet.

If someone checks in code that breaks the build, it will send an email letting you know it’s broken… the idea is that you are notified immediately that whatever you just did was a bad thing… instead of finding out days or weeks later.

Essentially a CI server helps avoid the dreaded

worksonmymachine

… instead of the typical build problems a new developer typically faces checking out code for the first time, anyone should be able to simply check the code out and build it and all the unit tests should pass.

I’ve used CI Factory and Team City before (see links below) but was impressed with how easy it was to configure Hudson.

CI links:

http://martinfowler.com/articles/continuousIntegration.html

http://en.wikipedia.org/wiki/Continuous_Integration

http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET

http://www.jetbrains.com/teamcity/

That really shouldn’t have taken that long…

Posted in Uncategorized by nelsonmichael on June 6, 2008

So lately I’ve been dabbling with jquery. Dabbling typically meaning searching for useful plugins and figuring out how to configure it with a couple of lines of javascript without really knowing what’s going on behind the scenes. Today I ran into a couple of snags where I actually had to have a clue what I was doing.

I’m slowly switching the application I’m developing from ASP.NET web forms to Castle MonoRail. I wanted dynamic select tags on a particular page and looked to jquery plugins for a solution (as opposed to using web form’s CheckBox tag with Autopostback=’true’).

I found a nice little plugin called jquery.selectCombo which was pretty easy to implement based on the instructions in the script file. Just call $(‘#mySelectTag’).selectCombo(url,’#targetSelectTag’); from document.ready and it will pass a parameter called q containing the currently selected value to the specified URL. The server side code needs to return JSON containing an array of objects with two properties: oT (text) and oV (value).

So far so good, not too tough once I figured out I needed to call RenderText(jsonText); from the controller to return the json to the calling page function.

Then I realized, however, that I needed to also pass the state of two checkboxes to the controller, since they would affect the query. Hmmmmm…. ok, no problem, I’ll just get the URL from a method instead of being static and then append two query parameters along with the state of those checkboxes. The selectCombo documentation said it’s no problem to include additional query parameters (whew). So I created a little function which would return something like: myUrl.rails?ShowFoo=true&ShowBar=false.

All well and good, until I tried it out and realized that the query parameters weren’t changing as the checkboxes changed state… oops, the URL was only being evaluated when the selectCombo function ran at $(document).ready. Bummer.

Ok, I figured, all we need to do is update that function when a checkbox changes and we’ll be good to go. Ummmm… how to you select all checkboxes in CSS again? I could have used a class, but at this point was really curious how to do it, so after a little digging I discovered that, while not supported by all browsers, $(‘input[type="checkbox"]‘) works just fine in jquery.

So I attached a click handler to all checkboxes which ran our friendly little method: $(‘#manager’).selectCombo(getAccountsUrl(),’#account’); which, I hoped, would update the account list based on the manager selection while taking into account the two ShowAll checkboxes. Unfortunately when I ran the page again, and selected one of the checkboxes… I still got the old checkbox values… then my controller method was called again with the correct values.

Of course, I was just attaching multiple handlers, not replacing the old one with the new (doh!). Hmmm… now I’ll actually have to figure out what’s going on. So I took a closer look at the selectCombo source code. It’s mercifully brief, but not very well formatted. Fortunately I discovered this handy utility which did a nice job of reformatting the code: http://elfz.laacz.lv/beautify/?

I saw a call to $.fn.selectCombo in the code and a quick scan of the jquery documentation indicated that this is important for creating plugins. So, instead of Reading The Fascinating Manual, I just tried setting that thingy to null before calling selectCombo again in the checkbox click handler. And, as I deserved considering I was just jiggling the wires, it didn’t work.

So, back to the source code, I realized that somewhere in all those curly braces, he had to be attaching an event handler to the source select tag. Sure enough, there it was. Another check to the jquery documentation and I realized it was really easy to unbind handlers in many flexible jquery-ian ways. I gave it a shot and, sure enough, it worked like a charm:

$(document).ready(function() {
     $('#manager').selectCombo(getAccountsUrl(),'#account');
     $('input[type="checkbox"]').click( function() {
     $('#manager').unbind('change');//remove previous event handler (with old URL)
     $('#manager').selectCombo(getAccountsUrl(),'#account');
     });
});

So simple… it really shouldn’t have taken that long (but it so often does).

A funny thing happened on the way to ALT.NET

Posted in funny by nelsonmichael on April 20, 2008

I was heading to the ALT.NET conference in Redmond this morning with Chris Bilson and we saw a license plate that said 404 – NOO!!!!! (ok, I added the exclamation points).

I was sure it had to be someone really geeky heading to the conference, but as we passed the car it turned out to be a little old white haired lady that likely had no idea how funny her license plate was… go figure.