Monthly Archives: March 2008

My First Contribution to Open Source

As you probably know from previous posts, I am a recent convert to Twitterism.  I totally dig the dirt simple minimalist web UI that the service provides, but I noticed that several of the people I was following were using some other kind of client to tweet with.  So I checked out the one I saw The Elder using, called Witty

Well, it turns out that he helped write the thing, along with Jon Galloway, project owner Alan Le, and several others.  It was a nice piece of WPF-y eye candy, and worked perfectly, too.  At least, as long as you weren’t behind a proxyI’ve mentioned my utter loathing of my employer’s proxy before (and in association with Twitter), and this just added insult to injury.  So, since it was open source, I decided to make a patch to add proxy support for Witty.

It took me most of an afternoon, but I’m sure others could have done it much more quickly.  The real meat of the changes were pretty darn simple, since the .NET API for performing HTTP requests allows a proxy configuration as an optional parameter.  But I’d never used TortoiseSVN before (a popular application used to interact with a Subversion source control repository), I’d never written an angle bracket of XAML, and I was looking at the codebase for the first time, so I cut myself some slack.  😉

So, by that afternoon, I had the changes working.  A few days later, after getting in contact with Alan and him patiently explaining the proper way to post changes (there’s a “Create Patch” option in TortoiseSVN), I submitted my changes for review.  Frankly, having never contributed to an open source project before, and coming from a development shop that is really just getting started in .NET (and thusly hasn’t provided a whole lot of guidance on good design), I was afraid my code wasn’t going to be up to snuff.  However, Alan contacted me later that day to tell me he thought my changes looked solid and that he had merged them with lots of other improvements contributors had made to the project.  That evening, he posted Witty version 0.1.7 Beta 1 to it’s Google Code page.  Code I wrote was officially available to the whole world!

It was a lot of fun working on the enhancement, and rewarding to think that I may have helped a person or two out.  There’s a lot still to work on, though.  For example, even though you can receive tweets through an authenticated proxy on Witty now, the avatar images don’t show up if you’ve got that same proxy configuration on IE.  That’s because the XAML elements used for the avatar images use the real twitter URLs as their source property, so the application uses IE’s configuration when going to get those images.  Since there’s no way to authenticate when the app makes those requests, you never get the images back. 

Anyway, such is the life of an OS app.  Always more to do.  I highly encourage you to find an open source project you like and take a crack at adding a feature or fixing a bug.  I had a great time doing it, and I plan to continue.  Not only is it rewarding to help someone out, but it also exposes you to others’ code, which can only help you improve your own style and technical chops. 

P.S. – Don’t forget to check out Witty:-)

P.P.S. – Note to other people at the company I work for: this doesn’t mean Witty works for us now.  The net nanny still blocks any web requests to a Twitter URL, so we’re pretty much out of luck. :-/

Excellent ALT.NET Podcast

Today’s Hanselminutes episode has Scott interviewing David Laribee, the guy who coined the name “ALT.NET.”  I think he went a long way toward explaining the motivations of the movement, as well as its position regarding Microsoft.  Several things he said actually surprised me. 

First, he said that an Agile approach may not be appropriate for all scenarios (specifically very large teams)…  Wha?  You mean Agile is not the panacea for all your development ills?  Sarcasm aside, even though many knowledgeable developers believe that Agile environments can benefit most teams (and I have neither the experience nor the will to contradict them), it’s good to hear such a non-dogmatic statement coming from an ALT.NET leader.

Also, in the same vein, he said that waterfall might not be bad in all cases, and that he had been a part of several successful waterfall-style projects.  Now that really surprised me.  Even mentioning the waterfall approach to building systems has been kind of a cue to pounce on someone (as in the case of Frans Bouma), so in this case as well, it’s refreshing to hear what seems to be a moderate voice.

It’s possible that David held back a bit during the interview; I really don’t know, since I haven’t read much of his blog.  But it could also be that I have committed the cardinal sin of letting the commenters on ALT.NET blogs color my perception of what the actual leaders of the movement believe.  All I know for sure is that I’ve got a new entry on my blogroll, and I feel like I really do need to stay tuned in to this influential segment of the software development community.

Ambivalence and ALT.NET

It pains me to say it, but ever since I tuned in to the ALT.NET movement, it’s kind of rubbed me the wrong way.  The content of the posts that I read are generally pretty good (and at times great), but what gets to me is the overall negative tone of the community.  Rather than just trying to get the word out about the cool open source (or just non-Microsoft) technologies that are out there, and the Agile methods and practices that can make your life easier, the prevailing message seems to be, “If you’re not already doing this, you’re a sub-par developer.”

I understand the need for a foil for Microsoft, the need for a periodic reminder that not everything that comes out of Redmond is gold.  But I think it can be accomplished in a more positive way.  In an email conversation with Jeffrey Palermo, I asserted that what we need are “Agile Evangelists,” missionaries into the land of Mort that can spread the word about the good news of a more Agile approach to software development.  But what we seem to get most of the time are complaints that Microsoft isn’t doing enough, and that bosses, co-workers, or fellow .NET community members are too dull to realize the benefits of what they’re touting.

You can see this dynamic in action if you watch the video of ScottGu presenting the very first peek at ASP.NET MVC to the ALT.NET conference in Austin.  For the most part, things go fine, but there a few tense moments where people asking questions are downright belligerent.  Since the MVC framework is a genuine (IMHO) attempt by Microsoft to reach out to this community, you’d think they would be a bit more cordial.

That said, I think their message is a sound one.  Most developers that I know don’t devote a lot of extra time to learning new technologies, and thusly have a limited perspective.  That’s not intended as an insult.  These guys program for 9 hours a day, there’s no reason to expect them to take more time away from their friends and families to tinker with the newest language they heard about on Twitter.  Those of us that feel compelled to do so, however, (I think) have a responsibility to at least make them aware that there are other things out there.  If the only exposure they have to this outside community is a blog post they stumble upon that rants for hundreds of words about how Microsoft will never release anything worth using and that all developers who don’t use technology X are just wasting their time, how likely do you think they’ll be to try technology X?  Ever? 

This isn’t in any way intended to be some kind of personal attack on those who actively participate in this sub-culture.  I think the ALT.NETers have a lot of good things to say, and a lot that they can teach the larger .NET community.  If they can temper their message a bit, I think they will reach enough of us that I think of as the “tuned-in small names” that there can be some progress in exposing Agile practices and open-source tools to the masses.

Inaugural Fort Smith .NET User Group Meeting

Thanks to the hard work of several people in the Fort Smith area, our first DNUG meeting was a great success.  Raymond Lewallen spoke on Behavior Driven Development, a subject I had been curious about.  I’d heard that it was the right way to do Test Driven Development, but little other than that.  Ray did a great job explaining the gist of it.  Since Mo has already listed some great resources on learning about BDD, I’m just going to highlight some of the things that were interesting to me.

First of all, the way Ray named his test fixtures and tests jumped out at me.  Normally in TDD (in my limited experience), you’d have a fixture named AccountTests to test an Account object, and tests named something like New_balance_should_reflect_old_balance_plus_deposit_amount.  Rather than doing that, Ray’s fixture would be named When_depositing_money_into_an_account and the test would be named New_balance_should_reflect_old_balance_plus_deposit_amount.  The difference there is that the context of the tests is defined by the fixture name, and the test describes the event and the expectation of the results of that event.  I think that’s a much better way to name your fixtures, and better leads you to what tests you need to write.  Ray said that that was one of the main goals of BDD, not just writing tests, but writing the right tests.

Also, he demonstrated a project he worked on called Spec Unit, which makes using assertions in NUnit easier.  Normally, you’d write an assertion in NUnit like this: 

Assert.AreEqual(250.00, account.Balance);

By using extension methods, Spec Unit allows you to write this instead:

account.Balance.ShouldEqual(250.00);

That reads a whole lot more like English, and thus makes it easier to understand what the test is doing (which is another goal of BDD).  It also includes some stuff to let you run some reports on your tests that help you track your development.  Definitely worth checking out if you’re writing tests in NUnit.

I’m afraid a subject this in-depth may have scared off some of the people attending the meeting who are fairly new to .NET, and may have not ever seen unit testing frameworks before.  I think the meeting on March 31st may be a little more accessible.  Chris Koenig will be coming to speak on Silverlight, which ought to be cool.  I’m hoping that he shows us some Silverlight 2.0 code, since that’s what’s really interesting to me.  If you’re in the area, please come to the meeting!  And stay tuned to the user group’s site for information on future events.

So There! :-P

What do you do when the Twitter site gets blocked?  Host a Twitter client yourself, of course!  Since Twitter exposes a public API (http://groups.google.com/group/twitter-development-talk/web/api-documentation), it’s very easy to set something up that gets your personal timeline and lets you update your own status.  Twitteroo makes it even easier to do from a .NET environment; many thanks to the guys at RareEdge for providing a library that abstracts away all of the WebRequest stuff. 

What I have is pretty ugly-looking right now, since I wasn’t very worried about how it looked, just that it worked.  I’m not displaying people’s pictures, since the images tags would result in requests to the Twitter server from the end-user’s browser and would get blocked.  I’ll make it work eventually, but it’ll require some gymnastics.  Something like having the aspx page do a web request for the image, save the bytes off in some temp directory, then change the tag to point to the temp directory.  That, plus a little bit of styling, and it should be passable. 

Feel free to use it as-is here.   You’ll just have to trust that I’m not stealing your username and password and using it to post embarrassing messages to your account.  ;-P  Also, be forewarned, it’s not the most secure thing in the world.  Just to get it to work quickly, I save off the password to a session variable, since I have to have it to pass to the Twitter API. 

I’m becoming a big fan of these open web APIs and services.  I’m thinking of using the Virtual Earth API in the site that I’m currently developing.  It fits the problem well, and it’s just so darn easy to use.  Conveniently, there’s also a DNRTV episode this week about using it in ASP.NET that I’m looking forward to watching tomorrow. 

Hooray for a web-enabled world!