Can’t have too many, only have too few. If an handler is doing more than 1 tasks the handler is doing too much. When following Google, NASA or any high disciplined programming guidelines for safe programming, the following handler is already too long:
on stringReplace(haystack, needle, replace)
tell AppleScript
set oldTIDs to text item delimiters
set text item delimiters to needle
set TIs to every text item of haystack
set text item delimiters to replace
set newStack to TIs as string
set text item delimiters to oldTIDs
end tell
return newStack
end stringReplace
The reason why the handler above is considered too long is because the handler is performing 2 tasks. The handler splits a string using an separator and joins an array into a string using an separator. Also if you would write an handler for splitting or joining a string using a separator there would be redundant code which indicates your handlers are too big. The correct code would look much more similar to this:
on stringReplace(haystack, needle, replace)
return join(split(haystack, needle), replace)
end stringReplace
on join(lst, sep)
tell AppleScript
set oldTIDs to text item delimiters
set text item delimiters to sep
set str to lst as string
set text item delimiters to oldTIDs
end tell
return str
end join
on split(str, sep)
tell AppleScript
set oldTIDs to text item delimiters
set text item delimiters to sep
set lst to every text item of str
set text item delimiters to oldTIDs
end tell
return lst
end split
We (referring mostly to myself) often post examples where handlers are performing too many tasks which gives a bad example. On the other hand AppleScript is an language for the hobbyist and not for aerospace programs. It therefore depends on how disciplined you want to write your code yourself.
Any handler that’s written (redundant) in more than 1 script should be in an library.
Debugging is mainly the biggest disadvantage, you’ll always need another script to call the handler. When you’ve created an hierarchical structure of dependencies simply copying the handler contents to a new empty script can’t be done that easily.
Don’t use it. It takes a lot of work to write the sdef files and limits your writing style because commands are not methods. Script libraries are OO, dictionary style is functional.
I’ve a free website astoolbox.wordpress.com for sharing my osax and share the link on this site and others. The actual osax you’ll download from my google drive.