vendredi 20 janvier 2017

How do you call this pattern where every operation returns a status class?

Does the following pattern have a name?

  • every function returns an instance of a result class (or structure, or associative array) that has at least these two public variables:
    • success: a true/false value to hold if the action completed successfully
    • result: a variable that holds the result of the function or nothing if the function is void.
  • if success is false an error variable may hold information (exception/stack trace/debug) about the error
  • also a message variable holding an user friendly message was defined in one case

I've seen this used both in .Net and PHP (both internally and in a script invoked by javascript ajax requests).

Aucun commentaire:

Enregistrer un commentaire