FileMaker 世界中模块化脚本的定义是什么?
如何在 FileMaker 环境中定义模块化脚本?我还没有故意提供我的定义。我想知道你的想法。谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
模块化脚本是一种执行有用功能的脚本,在该脚本之外没有外部依赖项。这与我所说的“一次性”脚本形成鲜明对比,后者只需要很少或不带参数,但具有特定于所使用的文件的依赖关系。
理想的模块化脚本需要零输入,执行一些有用的功能,并且不需要对其结果进行处理。一个示例是调整当前窗口大小以使当前窗口在屏幕上居中的脚本。由于没有 I/O 连接,并且脚本本身之外没有任何内容需要更改,因此使用此脚本无需任何成本。
更实际的例子将需要输入参数和输出结果。然而,请记住,随着参数传递的数量和复杂性的增加,模块化的好处会减少。有一个临界点,在这个临界点上,需要很少或不需要参数的“一次性”非模块化脚本的简单性是更好的选择。
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.
FileMaker 中的模块化脚本体现了面向对象编程的精神。即,脚本应该被建模为具有狭窄焦点的可互操作的功能对象/模块的集合。在 FileMaker 中,这些模块应该支持通过参数传递的值,而不是从当前上下文派生的值。脚本模块应该返回结果(例如,成功、失败、取消等)以及调用脚本中可能需要的值。较大的例程应该依赖于许多较小的模块来执行任务,从而使您能够轻松地查明故障,并允许模块可以重复用于许多任务。
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.
模块化脚本是一种编写脚本的方法,这样每个脚本在按原样复制到另一个解决方案时都可以在任何时候执行时正常工作。
“正常工作”意味着正确识别其自身的上下文和参数,并按照脚本中作为主要注释包含的文档执行正确的操作或报告正确的错误/结果代码。
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.
FileMaker 中的模块化脚本使面向对象编程的继承属性适应 FileMaker 工作方式的特定粒度。通过认识到 FileMaker 不是面向对象的平台,而是面向上下文的平台,模块化脚本希望尽可能实现复制和粘贴。
模块化脚本可以通过调用上下文传递给它们的基于值的参数或通过识别自身的操作上下文来控制自身。模块化脚本可能依赖于 FileMaker 系统中的某些模式结构,但可能不依赖于脚本通过参数告知或可以推断的内容之外的任何特定模式或上下文(例如通过 Get() 和 Design 函数)。
例如,模块化“打印报告”脚本可能需要被告知要打印什么布局,甚至可能需要通过 OnLayoutLoad 或 OnModeEnter 触发器对搜索结果进行排序,但模块化打印报告脚本宁愿不需要特定布局命名为“打印报告布局”或特定的“Table::SortThis”字段,除非这些字段对于给定解决方案中脚本的多个不同应用程序是通用的。
因此,可以调用单个模块化脚本来执行适用于许多不同上下文的相同任务。
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.