Script patterns – Test then act (final assessment)


Let's follow on from yesterday and complete the assessment of the four script solutions.

Extensible

For these solutions the extensibility would refer to being able to add another FileMaker client, such as distinguishing between Mac and Windows for FileMaker Pro. Extensibility may also be adding script steps such as Show all records or Sort Records for specific clients.

Scripts #1 and #3 are rated highly because each client is clearly defined. Script steps can be duplicated and the calculations modified quickly and easily. New script steps can be inserted as required.

Scripts #2 and #4 are easily updated in a single calculation to detect new FileMaker clients. In the case of #4 this would also need to be done in the $routing variable calculation. Neither update is onerous and both have the advantage of being done in a single location.

While additional script steps can be easily added for #2 and #4, they do not allow for different script steps per client. This would need an additional If statement to test the client or the layout and perform specific steps accordingly.

Scoring: #1 = 5, #2 = 4, #3 = 5, #4 = 4

Usable

When assessing usability we are asking how easy it is to reuse the script logic in another script in the same file or in a different file.

For #1 this is a simple matter of copying the script block and pasting it into another script. If this is in the same file then there is no need to check for the existence of layouts with specific names. If it is a script in a different file, there may be some broken Go to Layout steps if the layout name does not exist.

For #2 there is a simple copy and paste of just two script steps. As for #1, when pasting into a different file, you will need to check the layout names used in the variable calculation for $client. Missing layouts will not be as obvious as for #1.

For #3 the script block is being called from a subscript. This makes it easier to apply to another script. All that needs to be done is to copy the Perform Script step from an existing call and paste into another script. When doing this in a different file, the subscript will need to be copied and pasted, and then the Perform Script step can be copied and pasted into scripts in the new file. As for #1, the Go to Layout steps should be checked in the pasted subscript.

Solution #4 is similar to #2 – copy and paste the three script steps. For a new file, the $client calculation should not need to be checked. But the $routing calculation should be updated to match all layouts in the new file.

Scoring: #1 = 4, #2 = 4, #3 = 4, #4 = 4

And the winner is…

The total are in: #1 = 19, #2 = 15, #3 = 17, #4 = 16

So the winner is the standard If/Else If structure followed by the subscript which also used the If structures.

The other two solutions seemed to be ranked lower on the basis of maintainability and extensibility. Do you think this was a fair assessment?

Can we see any better solutions now?

We have done some significant assessment of the solutions here. There is no doubt that it is additional work to find at least three solutions to the same problem and then to assess each for the best fit. There are probably some other things that we could assess for more extensive scripting, such as performance.

While we came up with four different solutions, there are obviously more if we spent more time. So having done all this work, can we now see any other solutions that may be even better?

One suggestion that I have would be to use the If structure in #1 in the subscript for #3. This would bump up the readability score. And due to the use of a subscript it may actually win out over #1. This is because the layout navigation logic is centralised in and called from a single location.

On reflection, this was not considered when rating the maintainability of these solutions. Any updates to #1, #2, or #4 will probably need to be repeated in multiple scripts. Simply taking any of the logic from those solutions into a subscript would improve their maintainability.

What do you think?

Do you have any thoughts on this process? What else would you consider when comparing possible solutions? Do you use a more or less rigorous procedure to arrive at a good scripted solution?


Are you late to the ScriptLogic party? If you have missed out on some of these emails, catch up here: Email Archive​

​

If you know someone else who you think might like this email, you can send them this link to subscribe: Subscribe to ScriptLogic Daily​

​