September 17, 2008

Be careful how you call super()

Here's something all ActionScript 3 developers should know about extending classes and how parent constructors are called:

If class B extends class A, does class B have to call super() in its constructor in order to instantiate the parent class? Nope. What happens if you don't? The compiler inserts a call to the constructor for you. Usually.

The compiler just looks to see if you call super() at any point in your constructor. What if that call is inside of a conditional statement that evaluates to false? The default constructor won't get inserted, and the parent classes's constructor won't get called. Why is that a problem? You may very well get null reference exceptions since class level variables are often initialized in constructors. What's worse, you may only get them sometimes — only when your conditional statement evaluates to false.

Even if you determine that your code works whether super() is called or not, you still have to watch out. What if the implementation of the parent classes changes in the future? Code that used to work, and code that you could reasonably expect to continue working, may just break on you. I've actually seen this happen. It's not pretty.

How do you avoid this problem? Either call super(), or don't. Never put super() in a statement that may not execute, even if you find that your code works fine today since you never know what might happen to that parent class tomorrow.

Posted by cantrell at 10:41 AM. Link | Comments (5) | References

September 02, 2008

Apprise 1.1: More sharing, more features, and more languages

We just released Apprise 1.1 with several new features:

  • In addition to AIM and Twitter, now you can share posts via email, as well.
  • Post links directly to Facebook, Delicious, Digg, Newsvine, MySpace, Google Bookmarks, and Windows Live Bookmarks.
  • Smart topics. Only posts containing specific keywords will show up in your smart topics.
  • Configurable notifications.
  • Support for 16 languages: English, German, Spanish, French, Italian, Japanese, Korean, Portuguese, Russian, Swedish, Dutch, Czech, Turkish, Polish, and both Traditional and Simplified Chinese. Apprise will use the language of your OS, or you can change languages dynamically from the settings window.
  • Improved aggregation. We now show you post content, if it's available, rather than just a post summary.

We've also added some smaller features and polish, and fixed several bugs. If you're already running Apprise, it will auto-update. Otherwise, go check it out.

Posted by cantrell at 09:14 AM. Link | Comments (3) | References

August 06, 2008

How do you want to share with Apprise 1.1?

We're working Apprise 1.1, and we'd like some feedback. Apprise 1.0 allows you to share articles via AIM and Twitter, and for 1.1 (not out yet), we're adding the ability to share via email, as well. We're also adding Facebook, del.icio.us, Google Bookmarks, and Windows Live Favorites. What other services would you like to see us support? MySpace? Newsvine? Mixx? Let us know what you're using, and we'll do our best to get it in.

Posted by cantrell at 08:40 AM. Link | Comments (12) | References

July 28, 2008

Share stories right from your news reader

Over the summer, my intern Dan Koestler and I decided to get serious about Apprise, a news reader written for AIR. There are a lot of news readers out there, so the natural question is what sets Apprise apart? Here's a summery of what I believe are our most compelling features:

  • AIM integration. Send stories to your AIM buddies from Apprise rather than copying and pasting URLs into your AIM client. Apprise doesn't replace your AIM client -- it works alongside it to make sharing stories easier and more efficient.
  • Twitter integration. Post URLs to Twitter directly from Apprise. Again, Apprise doesn't replace your Twitter client, but it makes posting stories to Twitter much faster and easier.
  • Folders. We finally broke down and added folders, our #1 feature request. We now have folders for you to organize your own feeds, but Apprise still automatically organizes posts by author and topic, as well.
  • Automatic feed resolution. It's surprising how many sites don't make it easy to find their RSS or Atom feeds. Now you can just enter the URL of the site that you want to aggregate, and Apprise will find the feed for you.

Apprise has several other cool features like realtime search accross all feeds, OPML import and export, Vi keys, and site view. And it finally even got a nice design so it no longer looks like a developer designed it.

You can find Appirse at apprisereader.com. If you already have an earlier version of Apprise installed, you should be able to click on the badge and replace it, but you also might need to uninstall the old version first. This version of Apprise adds auto-updated, so from now on, you'll get new features and bug fixes automatically.

Continue reading "Share stories right from your news reader"

Posted by cantrell at 08:04 AM. Link | Comments (4) | References

July 02, 2008

Closing all your application windows in AIR

Here's a little snippet of code I sometimes use in AIR applications to make sure all windows close when the main application window closes. I usually put it in the main application MXML file (the main window of the application). It stops the main window from closing, and closes any other opened application windows first in the opposite order in which they were opened (more recent windows first). Without code like this, if you have any other windows open, even little utility windows, and your main application window is closed, your application will not exit, even if NativeApplication.autoExit is set to true.

this.nativeWindow.addEventListener(Event.CLOSING,
  function(e:Event):void
  { 
    e.preventDefault();
    for (var i:int = NativeApplication.nativeApplication.openedWindows.length - 1; i >= 0; --i)
    { 
      NativeWindow(NativeApplication.nativeApplication.openedWindows[i]).close();
    } 
  });

Posted by cantrell at 09:28 AM. Link | Comments (3) | References

June 16, 2008

AIR 1.1 and Apprise 1.5

Note: Apprise is now available at apprisereader.com.

With the release of AIR 1.1 comes a new version of Apprise, a feed aggregator written for AIR. Apprise is a work in progress with lots of additional features to come, but here's what we have so far:

  • Support for all versions of RSS and Atom.
  • Automatic categorization by author and topic.
  • OPML import and export.
  • Realtime search.
  • "Site view" (easily switch between the summary, and the site itself).
  • Check marks. Put a check mark next to posts that you want to keep track of and easily find again later.
  • Advanced sorting. Sort feeds, authors, and topics by name, or by number of unread posts.

Apprise 1.5 adds the following features:

  • Support for 11 languages. Apprise now supports German, English, Spanish, French, Italian, Japanese, Korean, Portuguese, Russian, Simplified Chinese, and Traditional Chinese. By "support" I mean the UI is localized into these 11 languages — the aggregator itself will support any written language.
  • Automatic feed resolution. Rather than entering a feed URL, you can now enter a site URL, and Apprise will automatically find and aggregate the feed associated with it.
  • Improved search. The search algorithm in Apprise 1.5 is much more advanced. Both the title and the summary are searched, and you can search for multiple terms in any order.
  • Improved "new post" heuristics. Apprise 1.5 is more intelligent about figuring out which posts are new in order to eliminate duplicates.
  • General polish. We added several little improvements like focusing the cursor where appropriate, and updating individual feeds' unread count during the aggregation process rather than updating them all at the end.

If you check the code out and build Apprise yourself, you can get even more features:

  • Copy support. You can copy post URLs to our clipboard for easy sharing.
  • Drag and drop. Drag posts into an IM or email window to share stories.
  • Vi keys. Well, J and K, anyway.

My new intern, Daniel Koestler, and I will be working on adding new features to Apprise this summer. And, of course, it's all cross-platform and open source, so anyone who wants to contribute features can.

The next version of Apprise (2.0) will enable the auto-update feature so you'll be able to pick up new features automatically. We consider 1.0 and 1.5 to be betas, so they have to be manually installed. Click on the badge below to have a look at what we have so far, and let us know in the comments what features you want to see next.

Posted by cantrell at 08:38 AM. Link | Comments (2) | References

May 13, 2008

Adobe Feeds Update II

Just a quick note to let you know that I fixed the Adobe Feeds web services. Also, just a reminder that if you're seeing "header length too long" error messages, clear your cookies, and the problem won't come back.

Oh, I also fixed the FAQ on Safari, so if you Mac users have been dying to read the FAQ all these years, now you can. Of course, you probably figured out the answer to your question by now.

Posted by cantrell at 11:30 AM. Link | Comments (6) | References

May 08, 2008

Adobe Feeds Update

The new launch of Adobe Feeds (MXNA) has gone well, but there are two issues I'm seeing people report:

  1. Maybe people have been getting "Header Length Too Large" errors. Interestingly, this comes from cookie-related code that CF7 tolerated, but CF8 doesn't. Anyway, the problem has been fixed. If you're still seeing the error message, clear your feeds.adobe.com cookies, and it will never come back.
  2. It seems the web services are broken. This is probably the result of the query optimizations I made. I didn't test all the web services, so they're probably incompatible with the changes I made. Oops. Sorry about that. I'll get this fixed in the next couple of days, and report back when they're working again.

We'll get Feeds back to 100% in the next week or so. Please be patient with us!

Posted by cantrell at 09:33 AM. Link | Comments (8) | References

May 05, 2008

The new MXNA (AXNA?)

First, I personally apologize for the downtime. We've been meaning to find MXNA a new home for quite a while now, and we finally decided to make the time to do it. Ironically, as we were working on moving the code over to the Adobe cluster, the old weblogs server went down in a big way. We're still not sure what happened, but for some reason, Java was core dumping a few minutes after starting JRun. Rather than spending too much time fixing the old server, we decided to look ahead, put up an "under construction" page, and focus on the new platform.

Mike Chambers and I wrote MXNA five years ago, thinking we would aggregate a few dozen popular blogs. 100 at the most. We initially put it on our own server which we expensed every month. When we outgrew that, we moved it to a single Macromedia server which Mike and I managed entirely ourselves. That worked out well for a couple of years until we outgrew it, as well. By that time, we were Adobe — a much larger company with more infrastructure — so moving it over to the cluster was a fairly involved task.

But we didn't just spread MXNA across a few more servers. As we began approaching 2,000 feeds, it became clear that the same code that managed 100 feeds wasn't doing such a good job managing 1,800. So I finally set aside a day, installed CF8, imported the production database, and with some pointers from Ben Forta (I'd never even used CF8 before — I've been focusing on AIR for the last two years), started optimizing.

I spent most of my time rewriting queries, and working on reducing the number of queries per request. The most dramatic change I made was optimizing the search query which went from about 30 seconds to one or two. Be sure to give it a try.

Again, sorry not just for the recent downtime, but for all the intermittent downtime over the last year or so. Hopefully we're past all that, and MXNA (AXNA?) will become a valuable community resource again.

Posted by cantrell at 09:08 PM. Link | Comments (22) | References

April 28, 2008

Weekend update to Newsbrew

A couple weeks ago, I blogged about a Google App Engine news aggregator I wrote called Newsbrew (original post). A few days later, Google announced the availability their RESTful feed API. Since the trickiest part of Newsbrew was the aggregation code, I decided to refactor the application to use Google's new service.

Newsbrew still stores feed and post data, but rather than retrieving and parsing the feeds myself (a surprisingly complex and error-prone process), Newsbrew now uses Google's REST feed API. All data, regardless of the underlying syndication format, is returned in a nice normalized JSON format.

With just a few hours of work, I was able to make Newsbrew much more robust, and because I no longer have code for parsing nine different formats of RSS and Atom, Newsbrew is much less error prone, and the code base is simpler.

I also added Ajaxian to the blogroll at the request of Dion Almaer. If you know of any other sites I should add, let me know.

Posted by cantrell at 11:32 AM. Link | Comments (2) | References