|XP is just a number
Re: Cool uses for Dancer/Mojo hooks (libraries over frameworks)by tye (Sage)
|on Dec 14, 2016 at 05:05 UTC
Frameworks are a pain, mostly because they end up needing hooks to be implemented. Hooks suck for more reasons that just it not being obvious what hooks should even be provided.
Libraries are a much better form of abstraction. Implement your functionality in properly abstracted subroutines with clear names that are easy to test. Then, if a user just wants the default behavior, they can just call the top-level subroutine and be done. If they want to customize parts, then they instead copy the structure of the top-level subroutine but add in their custom code where they need to. The top level subroutine should just be calls to other subroutines.
If you can easily test your subroutines and can give them clear names, then you've abstracted things well which means that the places where customization will be wanted are very likely to be "between" those subroutine calls.