Claim: Recipes should have a function Fn that determines whether or not to apply the recipe.
Goals
Debuggable
Auditable, in that the SUPER AWESOME REPAIR DEPLOYMENT BOARD should know why things are deploying or not.
Constraints:
Fn may be asynchronous or syncronous. Asynchronous behaviour should implemented through returning a Promise.
Fn may "allow" everyone, or no one, using any information at its disposal, including profile info, date, information from outside services, the phase of the moon, and the batting average of the Hanshin Tigers.
Fn should be exported as part of the recipe (Common/JS style).
To be valid, all recipes must have an eligibility function.
Current:
bool shouldRun(profile, [other arguments useful for testing, interactive, or command line])
Pro
Obvious return value and interpretation (bool).
Con
Hard to know 'why it failed', if there are multiple 'tests' or criteria.
Encourages 'first fail' design mentality. Not always what is wanted.
Proposal 1: Reverse the polarity of the neutron flow.
Rename to preventRun or skipRun or dontRun or stopIf.
Arity would be nullOrErrors stopIf(user_info, [optionals...])
Pro:
Still interpretable (in the negative)
Con:
Empty lists and objects are 'truthy' in js, annoyingly, so one has to be careful.
if it a list is returned
Proposal 2: Impartial Bureaucrat: Errors as an object, always
Rename to determineEligible
Arity is `nullOrAnalysis determineEligible (user_info, [optionals...])
analysis would be an object of
Pro:
Everything is explicit, explicit, explicit
Very very future proof.
Con:
Needs design of the returned object.
# something like
errors: list[ { name: , message: }, ....]
ranAllTests: (bool) # did we did all tests?
Questions:
Is Proposal 1/2 reasonable? If so:
Is nullOrErrors or null_TruthyVal_ListOfErrors or null_or_errorsObject a better arity?
If a list is returned, should the error handler have to know how to interpret it?
Is Proposal 1/2 better than current, such that it is worth designing around them?
Claim: Recipes should have a function
Fn
that determines whether or not to apply the recipe.Goals
Constraints:
Fn
may be asynchronous or syncronous. Asynchronous behaviour should implemented through returning aPromise
.Fn
may "allow" everyone, or no one, using any information at its disposal, including profile info, date, information from outside services, the phase of the moon, and the batting average of the Hanshin Tigers.Fn
should be exported as part of the recipe (Common/JS style).Current:
bool shouldRun(profile, [other arguments useful for testing, interactive, or command line])
Pro
Con
Proposal 1: Reverse the polarity of the neutron flow.
preventRun
orskipRun
ordontRun
orstopIf
.nullOrErrors stopIf(user_info, [optionals...])
Pro:
Con:
Proposal 2: Impartial Bureaucrat: Errors as an object, always
determineEligible
analysis
would be an object ofPro:
Con:
Questions:
nullOrErrors
ornull_TruthyVal_ListOfErrors
ornull_or_errorsObject
a better arity?