After some discussion we think it is best practice to return a
Chief::Result object from all Chief::Commands. We think this will lead
to easier to reason about code.
An example:
class Example < Chief::Command
def call
some_other_chief_command
end
private
def some_other_chief_command
Command::DoSomething.call
end
end
Code like this leads to a few questions:
Do we not care about some_other_chief_command failing?
Did we forget to to handle the some_other_chief_command fail case?
Is the caller handling the some_other_chief_command error?
Is the caller doing something with some_other_chief_commands value?
By enforcing every Chief::Command to call success! or fail! we can
force the developer to think about all of those questions and we can
help the future developer better understand the command.
After some discussion we think it is best practice to return a
Chief::Result
object from allChief::Command
s. We think this will lead to easier to reason about code.An example:
Code like this leads to a few questions:
some_other_chief_command
failing?some_other_chief_command
fail case?some_other_chief_command
error?some_other_chief_commands
value?By enforcing every
Chief::Command
to callsuccess!
orfail!
we can force the developer to think about all of those questions and we can help the future developer better understand the command.