Monthly Archives: May 2006

Using Rome to Generate RSS Feeds

I wanted to add RSS feed support to my project and ended up choosing Rome. I did this a while back so I honestly don’t remember the other toolkits I looked at. I do remember posting something and getting feedback pretty quickly from one of the Rome authors so I figured that the project was still pretty active.

It was pretty easy to generate a feed with the toolkit. I know that some people probably use it in more advanced ways or have more complicated needs but I just needed to be able to pass something a list of objects and have it spit out a feed in a particular format. Nothing too fancy.

Here’s a quick run down on how simple it is to create a feed:

 SyndFeed feed = new SyndFeedImpl();
 feed.setFeedType(format);
 feed.setTitle(title);
 feed.setLink(link);
 feed.setDescription(description);
 
 List entries = new ArrayList();
 for(Object item : listOfItems) {
     entries.add(entryAdapter.createSyndEntry(item));
 }

 feed.setEntries(entries);

In the code above the items such as format, title, link and so on are passed in to this function. The entryAdapter is also provided and acts as a translator to move data from a domain object(s) to a syndication entry (SyndEntry). There is generally one entry adapter implementation for each type of object I make availabe in an RSS feed.

The next step is to send the feed to an output target. In most cases you would just set this to be the servlet’s output stream. Here’s the code for that. Assume the Output is also provided as the writer instance.

 SyndFeedOutput output = new SyndFeedOutput();
 try {
     output.output(feed, writer);
 } catch (FeedException e) {
     throw new RuntimeException("Failed to write output", e);
 }

Rome supports multiple formats including all RSS versions and ATOM 0.3. I’m not sure if I’ll need more of the framework but they made it pretty easy to export feeds so it passed my first test. The next step is possibly caching feeds for popular requests so that I don’t have keep retrieving the necessary data and generating the feed.

Some Dancing and Some Trapping

The Evolution of Dance – I guess I don’t really go to YouTube very often but this was the most viewed video on YouTube at one point. Here’s the guy’s site as well. It’s worth the 6 minutes, it really is. And who here has done at least some of those dance moves before? Come on, fess up.

Trappers – This is one of my all time favorite Kids in the Hall sketches. “Let him go, he has spirit. Someday he might make vice-president”.

A Few Good Video Clips

I thought I’d start a video category and post links to fun videos I come across.

One of my all time favorites is an SNL video featuring Christopher Walken. Has there ever been a better character actor? Pulp Fiction, The Rundown, etc. Anyways, here’s the video – Blue Oyster Cult – I gotta have more cowbell!

Ever wonder where lifeguards go to the bathroom? Jamie Kennedy shows you here.

And if you haven’t seen Stephen Colbert’s roasting of President Bush, then you really need to watch this. Can you believe he did this with Bush sitting right next to him. His are made of steel I tell you.

What’s Up With Huge Resumes?

What’s up with huge resumes these days? The company I work for has been hiring lately and so I usually end up interviewing one to two people a week. Lately I’ve been seeing huge resumes from developers. I mean like 9, 10, and 11 pages for guys with maybe 7-9 years of experience. I have 12 years of experience and my resume is at 3 pages or so. It might have gotten in to 4 but I’m going to start removing stuff from jobs beyond 10 years I think. They’re not relevant and just make the resume go on and on.

Anyways, back to the relevant stuff. These resumes just go on and on (and ON) with mind numbing detail such as, “Configured log4j properties files”. What??? Why would I care about that. Great, you can use log4j, I must want to hire you now. But seriously, they put way too much detail about what they have worked on and I want to take a nap before I get through 2 years of experience. I just want bulleted items of the important things they actually did and/or were responsible for. These people are also the ones that didn’t run spell check on their resume usually. Hint: Education is not spelled with two Ts. What’s worse is that most of these resumes come from recruiters. I actually think it’s the recruiters that tell these people to fluff up their resumes. The recruiters should get dinged for not even proof-reading the resumes. Or at least lose a few % of commission. It’s just pathetic.

And last, people, get your resume right! Contrary to the belief of some, Struts is not a methodology. Neither is UML. UML is a modeling language, folks. The RUP is a methodology.

Another fun little tidbit: In Microsoft Office, if you type “JBos” instead of “JBoss” it will correct it to “jobs”. Proofread please!

Unit Test Code Coverage With Emma

Code Coverage Tools

While unit testing is a good start and it’s admirable to try and insure all your unit tests actually pass, it’s somewhat useless if you don’t know how much or what part of your code base doesn’t benefit from unit testing. Even the most committed developers of unit testing or TDD will miss covering some portion of their code. How do you try and prevent this from happening? Enter code coverage tools. The best known is probably Clover from Cenqua but for those of us working on our own home grown projects or that just like to use open source tools there is Emma.

Works Great!

I’ve been using it for MyThingo and it’s been very helpful. I’ve uncovered a few bugs that I didn’t know existed and hadn’t been uncovered by my unit testing up until now. Emma works by instrumenting your code and then you execute your unit tests using the instrumented class files. At runtime you set variables that tell Emma were to keep it’s coverage database and then after your tests execute you generate the report from that data. It seems to work very well and has a pretty comprehensive report of coverage including views of all your code with color coding to show which lines have and have not been executed during your tests.

Shortcomings

I have to admit that I miss the spit and polish that Clover seems to have. For example, Clover tells you how many times a line has been executed. While not critical it is a nice to have and I would expect this data is available in clover but just not exposed. If I get some time I may look into the report generating code and see what’s available. The integration of Clover in to Eclipse is also a very nice to have feature but again, isn’t critical.

Conclusion

Code coverage is one of those things that isn’t talked about much in unit testing circles. Okay, it is at times but not many developers I have worked with over the years really pay much attention to it. It is a critical part of your code testing infrastructure, however. You can’t just accept the fact that your unit tests pass. You must know how much of your code base is actually tested and then make sure that the parts that aren’t tested aren’t necessarily critical. It’s something I’ll harp on but in addition you have to make it brain dead simple. It has to be part of your build and not require any special attention by developers. It has to be part of your nightly build so reports are kept up to date as well. And finally, someone actually has to pay attention to the results and encourag developers to increase their coverage scores. If you do all this I think you’ll definitely see an improvement in the quality of the code that is delivered to QA and your users. And just think, better code going in to QA tends to mean shorter QA cycles which means faster delivery.

Transferring Eclipse Configurations

One of the pains of working with Eclipse RC releases is moving from one to another. I don’t like using downloaded plug-in packs such as WTP, Mylar, Spring IDE, TestNG, Subclipse, etc. because they get updated pretty frequently, especially to keep up with changes in the RC releases. But I also hated having to keep track of all the update site URLs that each of them has. Then, someone says, “Why don’t you just export your sites and then import them when you drop in a new Eclipse RC?” Doh! I have no idea why I missed that button before. Sometimes I just don’t look at the UI I’m using.

Visiting Fayetteville, North Carolina

I’m here in Fayetteville, North Carolina this weekend for my sister’s wedding, graduation and officer commissioning. I’m staying at this hotel (sorta) in Spring Lake which is next to Ft. Bragg. So, anyways, on to some interesting interesting observations.

There are two, yes two Wal-Mart SuperCenters within 20 minutes of my hotel, both in the same direction. Yet, there is only one Starbucks. Not exactly sure what to think about that except for the fact that I can’t stand Wal-Mart.

I’m also not sure I’ve ever seen so many strip clubs and adult stores in one area. Yes, there’s a big military base here but you’d think with it being in the bible belt that they’d be less obvious about it. But then again, there are some god-fearing folks that don’t seem to mind a little action every now and then.

Otherwise it seems like a pleasant enough place…and congratulations to my sister, Jennifer. You looked beautiful on your wedding day, sis! Have fun with helicopter pilot training! I’ll post some photos for my trip soon.