|
If you're a Major League Baseball fan and haven't seen it already, there's a great website out there called The Hardball Times that includes great daily articles as well as a wide variety of baseball statistics, especially some of the more hard-to-find Sabermetric stats like Win Shares, Pitching Runs, and Runs Created. I admit this is partially a shameless plug since I volunteered to develop the code for the statistics pages, but I have to say it is pretty darn nice stuff. If you're looking for baseball stats that you can sort and limit any which way you want without having to wait 30 seconds for a banner-ad-polluted page to render, The Hardball Times stats pages are probably something you'll appreciate.
For the techy folks, given that this is a Sun Microsystems-hosted blog, I developed the code in PHP 4 (I wish it were 5, but sometimes you have to deal with what the hosting company uses), Smarty, and MySQL 4.0.x. I used the great Propel object persistence and query toolkit for PHP, which is essentially a PHP version of Apache Torque, a peristence layer for Java. So far it's been great, but I do run into the occassional memory limit since our web host kills scripts that use more than about 16MB, and a Propel object can take up quite a bit of memory. I only run into this problem when running database loading scripts though, which cycle through all the players and do a lot of simple calculations to generate the various statistics. I also use some home-grown DB query classes for common queries that aren't Propel-friendly or efficient (at least in how I use Propel). The problem with a persistence layer that maps an object to a database table is that each object is generally an entire row of the table. If you need something like the average batters faced per game for pitchers in the American League, a persistence layer isn't really the way to go. I still abstract my queries from the DB using PEAR::DB (I could certainly use Creole, which is what Propel uses), so at least I've preserved some level of portability.
The coolest thing about this Hardball Times code is that I made most of it completely generic--it's sort of a framework really. Other people can use a web form to make changes to the sortable stats tables, including which columns are displayed, what the title of the column is, whether it should be included in the sort and limit drop-down lists, and what order the columns are displayed. All that is needed to add a new sortable web table is a group of Propel classes for the table and you're ready to go. This has come in very handy for my real job at Sun, where I create web applications to display statistical information on manufacturing data (such as fail rates, control charts, etc.).
For future PHP projects, I think I'll use the new Cake web development framework based on Ruby on Rails. I've tinkered with it a bit and so far it's great. One big advantage is that you don't have to generate the ORM classes for your database tables (although this is pretty easy with Propel), which makes updates to your code, especially database changes, quicker to implement.
(2005-07-29 11:46:58.0/2005-07-23 14:26:22.0)
Permalink
Trackback: http://blogs.sun.com/bdonovan/entry/attention_baseball_fans
|