Sunday, December 28, 2008

Case-Shiller Futures added to Home Price Charting Application

The S&P/Case-Shiller Home Price Indices Futures quotes are now included in the charts and data tables in the Lightsblue Home Price Charting Application. This data indicates where buyers of futures contracts on the Chicago Mercantile Exchange foresee the housing market going in Boston, Chicago, Denver, Las Vegas, Los Angeles, Miami, New York, San Diego, San Francisco, and Washington D.C. This information is updated daily.

Thursday, December 4, 2008

Case-Shiller Home Price Charting and Visualization Application

My family has been in the market for a house for several years now. A home in Boston is a huge investment, so naturally I've been curious about where home prices are headed. The S&P/Case-Shiller Home Price Indices measure home prices calculated from data on repeat sales of single family homes. Until recently, at the end of each month I would download the numbers in the form of an Excel spreadsheet, and manually chart and analyze the data. Finally, a couple of weekends ago I developed a simple Flex Application that uses the Advanced Data Visualization Framework to generate line graphs of home prices relative to 2000, month over month changes, and year over year changes.

So go check out the Lightsblue Home Price Application.

Alternatively, you can subscribe to the Lightsblue Home Price Feed, which will be updated when new features or data is added. The latest Case-Shiller home price data is currently published the last Tuesday of every month by S&P.

Tuesday, November 18, 2008

Lazily Loading List Items in Flex

When using Flex controls with a large dataset, it's often too expensive to load the items in the list all at once. In some scenarios you may find yourself using a third-party API which dictates that you use pagination by only allowing you to load a maximum number of elements at a time. In these scenarios, one of the more elegant solutions is to implement an IList that lazily loads items as they're requested.

I've implemented an example application which demonstrates two variants of this technique. The source is available via the normal right-click on the application mechanism, or via this link.

The first variant (in the first tab of the example application) immediately throws ItemPendingErrors when the list item hasn't previously been loaded. The flex framework supports asynchronous loading of items requested via the IList interface via ItemPendingError. Most Flex controls participate in the ItemPendingError contract, including List, HorizontalList, TileList, DataGrid, Menu, and Tree. When an IList (or ICollection) throws this error, the control gracefully handles it by registering a new IResponder with the error. The control's callback is called asynchronously when the results eventually are available, allowing the control to render the items as they become available.

The second variant (in the second tab of the example application) begins by synchronously returning partially loaded items to the List control, immediately requesting a page of details as the abbreviated version of each item is requested. The LazyList then replaces the appreviated version with the full version in the background, dispatching the appropriate CollectionEvent. The asynchronously dispatched CollectionEvents allow the control to render the details of the items as they become available.

Thursday, October 2, 2008

Flash HTTP Client Limitations

Flash currently has no legitimate HTTP client when running within a browser. If your Flash browser application needs to integrate with a REST service, you may find your self having to write a bunch of extra code to work around Flash's limitations. Your two options when using the Flash APIs are flash.net.URLLoader and mx.rpc.http.HTTPService. HTTPService actually uses URLLoader internally, so any URLLoader limitations are passed along to HTTPService. URLLoader's largest limitation is its inability to send any request with an HTTP method other than GET or POST. Note that these aren't the only limitations - there are many others, as well as some interesting quirks.

When confronted with these limitations, I considered the following workarounds:
  • FDS Server Proxy - This would require every HTTP request to hit the FDS server, followed by the target REST service.
  • Homegrown Server Proxy - This essentially would be a free alternative to FDS. The actual HTTP request sent by the client would have to have to be wrapped in an HTTP POST, and the POST would include information about the actual HTTP method desired. The legitimate HTTP Client on the server-side would then send the actual HTTP request with the appropriate method to the REST service.
  • Flash Socket API - This seemed like it had potential, however I had the added restriction of HTTPS communication with the REST service. Some third-party libraries such as as3crypto exist which have limited TLS 1.0 support, but the code was very new at the time, and I probably would have ended up writing a lot of HTTP client code.
  • Browser's native HTTP Client via XML HTTP Request + flash.external.ExternalInterface - Basically flash calls out to a javascript method which sends the actual HTTP request. The javascript function then calls back to flash when it receives the response. This is the option that seemed the least like a hack, and required the least amount of work. It's working rather nicely so far.