Some of you will remember my rant about open source, and how I couldn't find time to do it and didn't know how anyone could. That post caused a big backlash, lots of people wanted to know how I could say that without ever trying it. Many more shared their personal experiences getting involved in open source and loving it. They explained that it was something you MADE time for. So, to see if they were right I did make time. Let me just tell you, totally worth it.
Witty is a WPF project brought to you by some of the guys that do the Herding Code podcast. I initially reached out to Jon Galloway to see if I could get involved with their project. He explained that anyone that wanted to could get involved in Witty, and he linked me to this post by Scott Hanselman.
The post was very educational about the process for contributing, but I am no Scott Hanselman. There is a lot of green still left around these ears, and whether or not Scott Hanselman can do something is no indication if I can do it. I knew I would run into issues working on a new application in a new framework I hadn't seen yet (WPF). However, I tried it anyway and I was able to contribute a conversation viewing module to this past Witty release (2.2). I can't tell you how cool it is to think of the fact that so many people use this awesome project and I had a hand in it.
I thought that I would demonstrate to you guys how easy and rewarding it is to contribute to open source no matter what level you are at.
Ok, so the first step is figuring out what change you are going to make. I find that the best way to to do this is to actually use the application.
I actually got this idea for a feature through a tweet someone sent me about usernames not turning into links when they are prepended by a character. This became more noticable when the changes to replies were made and people were leading off
their tweets with a character so all their followers could see. So, I figured we could change this today.
Step one is getting the checking out the application through SVN. If you haven't done this before check out this tutorial.
Now, what you want to do next is up to you. Some people might want to take a look around first, see how the application is set up. I did that initially, it enabled me to get a handle on how things where done and where things are located.
I looked around at the file structure and kind of got a feel of where they stored things, there is a twitter library, and then the main application where the xaml is stored. Also, a skins project, common classes, and a test project.
Our first task today is to find where the usernames are being set as hyperlinks. My initial thought was that it was in the code behind for our xaml files. Or possibly directly in the xaml as a regex. I took a look around and didn't find anything. It was frustrating, but after I pursued that direction for a while I thought to do a Cntl + Shift + F search for the character @. So I did that and found this region in my seach results:
Jackpot! I found where they were setting the username as a hyperlink here in the OnTweetChanged method:
As you can see they are treating each tweet as an array and then iterating through that array to check the words for @usernames and #hashtags. Initially, I was going to have this loop check for a word
either starting with, or having the second character be @, but then it occured to me that we only want to check that first word in the tweet, since this issue is only an issue in that first word. It's adding more checks to each word to throw the logic into the loop and there has to be a better way
to do it.
I figured a great way to do this would be if I could separate the initial character and the @username into two separate parts of the array. I knew you couldn't insert into a string array, but you can with an arraylist.
I turned the array into an Arraylist and then I can make the first character and @username two words in the array. Then the loop will treat the see the @username for what it is and make it a link.
I was all set to check this in when I realized how much of a performance hit making the array into an Array List would be. So, I've gotta come up with something else. I decided to remove the functionality to format the @username from inside to loop, make it a method and call it before entering the loop if it falls in our char+username if statement, then call it from inside the loop if it is an actual username within the tweet.
There we go and here are our final changes to the OnTweetTextChanged method:
I tested again, and we're looking great.
Step next: submitting our patch.
What you want to do is go to the svn folder where everything is contained right click as if you were committing your work however go to "Create Patch" instead. Select the files you changed and save the patch somewhere.
SVN will show you a diff for your changes, go through and make sure you put everything in the patch.
Now go to the Witty issues list, and submit your patch along with a comment about what it is doing and then submit!
That's it! We're golden. All together it took a little over an hour What have I gained here?
1. . I got to add a feature I wanted to an application that I use.
2. After I submitted my first patch I got great feedback and critique from a developer I really look up to (Jon Galloway). You can have the same experience as long as the project you are working on is run by people you think are interesting.
3. I got to work with a new framework.
4. I feel like I've contributed something to the community, I walked around smugly for at least a few hours (j/k, but it's cool).
Anyway, I hope this encourages you to get started. I'm certainly glad I did.
Now if only it would stop constantly crashing on Win7 64b.
ReplyDeleteI've found that many folk on open source projects are extraordinarily helpful.
ReplyDeleteI've been talking to a bunch of folks in the Twitter development community over the past few weeks because I'm developing a new Twitter client. Everyone's been super helpful, even when I know they're being deluged with questions about their stuff.
Now I just have to remember to be that helpful when someone has questions about MY stuff.
What is this ArrayList class you speak of, didn't that go away in .Net 1.1? :-)
ReplyDeleteNice post Sara. You actually have some code in this one! ;-)
ReplyDeleteBy the way... you might look into incorporating a syntax formatter into your blog instead of just doing screenshots. Would make things a LOT easier to follow. I'm using Alex Gorbetchev's SyntxHightlighter now. It seems to be the most popular out there.
Great Post Sara.
ReplyDeleteI have been thinking about contributing to open source as well for some time, and this was an encouraging read. Now If only I could finalize an open source project to work on :).
Nice post.
ReplyDeleteSmall observation tutorial link given for subversion is for 1.0 which is quite old now.
Submitting a patch without a test for it? :)
ReplyDeletePersonally I work on projects that I actually use in real life; currently I'm writing tests for the 2.x branch of the Doctrine ORM which I will use in my applications. Contributing is a great way to care about the project health and to learn big things about something, expecially if it is a tool or a library.
Well said Sara, two other great reasons to patch OS is personal networking and also the experience. In today's shaky market, it is always good to know someone and something new :)
ReplyDeleteGood article!
ReplyDeleteGreat article!
ReplyDeleteEven bookmarked it for future reference :)
Hello,
ReplyDeleteI was trying to download witty code using Tortoise SVN Client,
it is asking for username,password credentials.
Can you please explain how to get the source to get started.
Nice post.
ReplyDeleteI've been interested for some time in participating in some OSS projects, but was a little intimidated and unsure about how to get started. Maybe I'll take another stab at it.
Similarly to John above, I'm still a bit shy to really try and contribute, but now that I think of it, this is silly. Professionals aren't going to mock me like the rest of the internet if I fail, right ?
ReplyDeleteThat's easy to do it after your post, thanks!
ReplyDeleteWhat a wonderful blessing indeed. I love good news like this.
ReplyDelete