There is a principal in software design called "Fail Early”, "Fail Fast", or "Fail Early, Fail Fast”. For this post, I am going to use the term “FileMaker Fail Early” to share some thoughts about how this principal applies to FileMaker software development...
Let us look at the common use case where a user clicks a Button on a Layout that runs a Script. For the Script to succeed, there might be a number of conditions that must be true, for example, there might be:
- Object Names that the Script references
- Fields that must be empty (or not empty)
- Related records that must be present (or not present)
- Required Plugin(s) (with versions)
- Feel free to add your favorites below
- Users privileges. // thanks @harvest
- Hidden errors that show up when you commit record // thanks @mrwatson-de
- Share points are mounted // new, from yours truly
A “FileMaker Fail Early” strategy lets us keep our Script as simple as possible by failing (dare I say Halt Script'ing) before we change state...
- Layout
- Window(s)
- Found Set
- Etc.
…and then needing to "clean up".
We are polishing and updating our “FileMaker Fail Early” Scripts. Below is one:
- Which of the 3 lines do you prefer: 8, 9, or 10?
- What do you think of the Script name?
- Other thoughts?
Considering that we put this Script in almost every File, how would you comment?
- Comment each section in the script in-line
- Single line comment at the top
- Let the Script name be the comment
- Link to a web page that documents all the “FileMaker Fail Early” Scripts
- Other?
This post is, in part, a followup on this presentation
DIGFM: Code Review, ♫ It's Getting Better All the Time ♬ (5/9/2024)
https://www.youtube.com/watch?v=oPZ_sJHVHVM&t=2288s
The goal of the presentation was to show some good code and some bad code...easy to do if you [don't] think about it
"Failure is an option” — unless you are watching a movie