Best Practices for Script Based Frameworks

Sannyasin Brahmanathaswami brahma at hindu.org
Sat Mar 26 02:57:17 EDT 2016


We are launching into the creation of a new app. I hope to use script stacks as much as possible and also we will have a lot of API's on our web server running under LiveCode server + RevIgniter in some cases, since Ralf's Libraries are fantastic and we don't have to reinvent the wheel for many functions.

My question is this: In the matter of scripts, libraries, includes etc. Do you as a developer prefer to keep discrete functions in separate files? Or do you use larger scripts with many functions/commands?

Here is a use case to consider:

One of the screens in the app will deliver "Surprise Inspiration" (random selections)

The user will be able to click on "Audio" or "Video" or "Art" or "slideshow" or "Quotes" and a few other text media genres

The app will ping the server with a media type and the api(s) on the server look into our media metadata database and select a random audio, build an absolute URL to the file on disk and send this back to app, which then

Run it in a player
Show it in a browser widget
set an image filename
Load a textReader card/field

Now, each unit in this scenario is relatively simple and we've been doing this "random whatever"  media delivery thing for years already.

But I want to start fresh. On the server we have some gigantic controllers (2000 lines) e.g. site.lc and cms.lc, with dozens and dozens of commands and functions.  And we also have /libraries with things like "utils" and "audio"  libraries with multiple functions. But they are much more discrete, limited.

So: would you create a single script and pass the media type to that script to look up? or multiple scripts. The random function is common to all the media types... so then this would seem to call for a single script, since whether we ask for an audio file, a book, or a video or a slideshow.. the random function that check the database will be the same for all....

OR

do you create small mini "get random media" script  and a separate script for each media type that includes that file? this seems better for re-usability. since someone else on the team can include "getRandomMedia.lc"  and it is obvious where it is and what it does. The downside of this is, proliferation of lots of little files!

  The Livecode IDE seems to have lots and lots of small script stacks. In the world of PHP web CMSs  we see a lot of waffling one way and the other... many of them use 3rd party modules and even across those, there are (obviously) different styles.

What do you do, how do you like to work and why is one way better than another?

What criteria do you use for

a) adding more functions to a single script/stack
b) making it an independent "mini" library/include

?

BR




More information about the use-livecode mailing list