Script design patterns: single responsibility and naming
ExpertStructure FileMaker scripts around single responsibilities and apply consistent naming conventions so solutions remain maintainable as they grow.
What you'll learn
- How to apply single-responsibility to FileMaker scripts
- A practical naming convention for scripts organized by context and action
- How to organize scripts into logical folders in the Script Workspace
- How to distinguish navigation, data, UI, and utility script categories
- How to identify and refactor a script that violates single-responsibility
A FileMaker solution with hundreds of scripts becomes unworkable when every script does ten things and names follow no convention. Applying the single-responsibility principle -- each script does one thing well -- combined with a predictable naming scheme turns the Script Workspace from a maze into a navigable catalog. This is the architectural investment that separates maintainable solutions from ones that must be rebuilt every few years.
Apply the single-responsibility principle
A script should have one reason to change. "Save Invoice and Send Email and Update Status and Print" should be four scripts called by one orchestrator. Each sub-script can be tested, reused, and replaced independently. If you cannot summarize a script's purpose in one sentence without using "and", it has too many responsibilities.
# Anti-pattern: one script does everything # Script: "Save Invoice" # - validates fields # - commits the record # - sends a confirmation email # - prints the invoice # - updates the client's balance # Better: orchestrator + focused scripts # Script: "Invoice - Process Submission" Perform Script [ "Invoice - Validate" ; Parameter: $invoiceID ] If [ JSONGetElement ( Get ( ScriptResult ) ; "success" ) = "false" ] Exit Script [ Text Result: Get ( ScriptResult ) ] End If Perform Script [ "Invoice - Commit" ; Parameter: $invoiceID ] Perform Script [ "Notification - Send Invoice Email" ; Parameter: $invoiceID ] Perform Script [ "Client - Recalculate Balance" ; Parameter: Clients::ClientID ]
Sign in to track your progress and pick up where you left off.
Sign in to FM Dojo