views:

239

answers:

4

How do you define modular scripting in the FileMaker context? I am not providing my definition yet on purpose. I want to know what you think. Thanks!

+1  A: 

Modular Scripting in FileMaker embodies the spirit of object oriented programming. I.e., scripts should be modeled as a collection of interoperable functional objects/modules with a narrow focus. In FileMaker, these modules should favor values passed via parameter in lieu of being derived from the current context. Script modules should return results (e.g., success, fail, canceled, etc) as well as values that might be required in a calling script. Larger routines should rely upon many smaller modules to perform a task, allowing you to pinpoint failures easily, and allowing modules to be reused for many tasks.

Dave Graham
Good answer, could use more heckle :) The point about not relying on context is an interesting one. I'd agree, but for FileMaker's unwieldy parameter support. I wonder if you could consider the context itself a "parameter". For example, before calling a modular script which affects / displays some record(s) in the found set, make sure you've got the correct found set and layout before calling the modular script, as opposed to passing in parameters for layout name, search field name, search value, sort by, etc.
Sam Barnum
A: 

Modular Scripting is a way of writing scripts so that each and every script, when copied as is to another solution, will simply work properly when performed at any time.

To "work properly" means to correctly recognize its own context and parameters and either perform the correct action or report the correct error/result code in compliance with the documentation which is included with the script as a leading comment.

HOnza
A: 

Modular Scripting in FileMaker adapts the inheritance property of object-oriented programming to the particular grain of how FileMaker works. Modular Scripting aspires to be as copy-and-pastable as possible by recognizing that FileMaker is not an object-oriented platform, but a context-oriented platform.

Modular Scripts may control themselves by value-based parameters passed to them by the calling context or by identifying the operating context for themselves. Modular Scripts may depend on certain patterned structures in a FileMaker system, but may not depend on any particular schema or context beyond what the script is told via parameters or can infer (such as via Get() and Design functions).

For example, a modular "Print Report" script may need to be told what layout to print, and may even require that the found set be sorted by an OnLayoutLoad or OnModeEnter trigger, but a modular Print Report script would rather not require a specific layout named "Print Report Layout" or a specific "Table::SortThis" field unless these are common to multiple distinct applications of the script in a given solution.

So a single Modular Script can be called to perform the same task as appropriate for many different contexts.

Jeremy Bante
+1  A: 

A modular script is one that performs a useful function with no external dependencies outside that script. This is in contrast to what I'll call a 'one-shot' script, which takes few or no parameters but has dependencies specific to the file that it is being used in.

The ideal modular script takes zero inputs, performs some useful function, and requires no processing of its results. An example of this would be a script that resizes the current window to center the current window on the screen. Because there are no I/O hookups and nothing to be altered outside the script itself, there is no cost to use this script.

More practical examples will require input parameters and output results. However, keep in mind that as the number and complexity of parameter passing increases, the benefit of modularity decreases. There is a tipping point at which the simplicity of 'one-shot', non-modular scripts that require few or no parameters is the better choice.

Jesse Barnum
I am with Jesse. Modular scripting, to me, simply means no external dependencies; scripts are copy/paste-able from file to file. No-parameter-scripts such as window management, have their place but at some point you need to know which layout, table, field, etc. Requiring that no parameters be passed severely limits modular scripting. I have heard many debates where developers use no-parameter modular scripting throughout their systems. This requires the use of strict naming conventions that, to me, are too precarious. Maybe I have just spent too much time as Queen Band-Aid.
Lauren Kuhlman