Posted on Thursday 23 December 2004
I had to rework some functionality in a movie I made for a client a long time ago, a dealer locator. The backend was originally handled by PHP and sent back to Flash in XML, an ugly but working solution. Since I'm developping AMFPHP 1.0, I decided to switch over to Remoting and see how that would work out.
Well, I shaved off about 40% of the PHP code and stayed about the same number of lines in actionscript. This is despite having added much better error handling, debugging functionality and much needed readability. In addition, I can use the service class for the admin area, while previously I had to recreate the coordinate finder for it, which is bad, especially when you consider the 'SQL from hell' it creates::
SIN(RADIANS(latitude/10000))
+ COS(RADIANS(340888/10000))*COS(RADIANS(latitude/10000))*
COS(RADIANS(longitude/10000 - -1184061/10000))))), 2)
AS distance FROM dl_dealers WHERE country = 'US'
AND `type` = 0 AND (latitude BETWEEN 304703 AND 377072)
AND (longitude BETWEEN -1227753 AND -1140368) AND
(ROUND((69.09*DEGREES(ACOS(SIN(RADIANS(340888/10000))
*SIN(RADIANS(latitude/10000)) + COS(RADIANS(340888/10000))
*COS(RADIANS(latitude/10000))*
COS(RADIANS(longitude/10000 - -1184061/10000))))), 2)
< 250) ORDER BY distance ASC
Performance is just about equal, but honestly it's much too fast (in the XML and in the remoting version) to properly assess the speed difference; both are basically instantaneous. Yet the debugger and the flexibility of Remoting makes me extremely happy to have spent a day making something work that was already working!



Sorry, the comment form is closed at this time.