Preferred Multi-Platform Development Method

Richard Gaskin ambassador at fourthworld.com
Fri May 8 13:18:42 EDT 2009


Derek Bump wrote:
> I'm just curious, but for those of you who have an Enterprise license,
> how do you develop your stacks/standalones for multiple platforms?
> 
> Do you keep each platform separate and write the same stack for each
> platform itself?  Or do you have 1 stack file and use Property Profiles
> and platform() functions to determine functionality?

I maintain only one code base, using forked code within specific 
handlers as needed.

For example, most of my apps use an InitApp handler, which call a list 
of specific handlers like InitPrefs, InitWindows, InitMenus, etc. Each 
of those handlers takes care of any changes I need for specific platforms.

InitWindows sets the backgroundColor, textFont, textSize, and other 
common properties for each window to match conventions on the target OS. 
  This happens one time before any windows are rendered so the 
performance hit isn't noticeable (my Rev-based apps generally boot in 
less than 1/10th the amount of time needed to boot any Adobe app, but 
that's not really fair since Adobe apps are almost always a favorable 
performance comparison <g>).

Same with things like Prefs.  I have two handlers I use everywhere, 
fwGetPref and fwSetPref to get and set preference values which are 
stored as custom props in a stack file. Each of those handlers calls a 
function named fwPrefsPath to get the path to the stack I use as the 
prefs file for each platform:  for OS X I use 
specialApplicationFolder("preferences") and for Win I use 
specialFolderPath("26"), followed by a folder for the publisher and then 
a folder inside that for the product where I store the actual prefs 
stackfile.  So one handler takes care of the forking, and nothing else 
in my app needs to care about which platform it's running on to get and 
set prefs values.

A rule of thumb I use for platform-forked code:  "Will I need this 
anywhere else?"

Any time I think I might need to fork code by platform, I'll write a 
separate handler for that so I can just call that and it'll take care of 
it without me having to ever think about it again.

This was especially helpful recently with a project I'm porting to the 
web, in which we have a fairly complex custom search engine for which 
all the path references to the index files are handled in generalized 
handlers that take care of any platform stuff.  While we'd been using 
this in the desktop product for both Mac and Win for years, I was able 
to just drop that search library onto our Linux server and call it from 
a CGI without having to modify it at all other than to reformat the 
output as HTML. :)

--
  Richard Gaskin
  Fourth World
  Revolution training and consulting: http://www.fourthworld.com
  Webzine for Rev developers: http://www.revjournal.com



More information about the use-livecode mailing list