Skip to content

paradigm shift in handling function returns

License

Notifications You must be signed in to change notification settings

valstat/valstat-rfc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Valstat is a Kind-of-a-Contract

Call Response Agreement

"... If you look at the source of your program, you'll notice routines that you call, but which you didn't implement..." -- Peter Van Der Linden

Valstat is a software architecture paradigm. Valstat is not yet another error-handling idiom. More precisely valstat as a protocol, is a paradigm shift in unified logic of creating a call response and handling the payload returned.

I am in a rush

OK, here you are. In the language you need to use, implement valstat as a light structure of two fields. The field in many business systems languages is option<T>; it can be empty or occupied; when not empty it has a value of type T. Call the first field Value and the second field Status

// VALSTAT pseudo code synopsys
{
   option value
   option status
}

you call the function and it returns such a structure. You use it in two steps:

  1. what is the call outcome?
  2. depending on the outcome what is the value (if any) or what is the status (if any)

The key is: that every interface method has to return valstat type. Everybody has to agree on the Valstat two-step usage. That also dictates how are valstats made. Everybody can be a team, a project, a system, a company, or wider than that. The wider the better. One can return valstat types using JSON, HTTP, XML, SQL, or whatever else.

Documentation

valstat documentation is deliberately technical, short, and to the point. The prose is left to be authored in future texts in response to future criticisms, comments, and clarification requirements.

valstat concept is designed to be platform and language-agnostic.

There is a root document describing the core concepts. There is also a number of repositories describing the various implementations in a few widely used programming languages.

  1. valstat Concept
    1. The language agnostic, conceptual, root document
  2. c implementation
    1. planned ISO WG14 proposal
  3. c++ implementation
    1. ISO committee WG21 (LEWG) Proposal P2192
  4. javascript implementation
  5. c# implementation
  6. go implementation

Together a concept and its implementation are making a behavior pattern.

Contact

In case you still like to use exceptions, here is the latest C++ official paper on the cost of exceptions in C++.

In case you hotly dislike this work, or if the situation is the opposite, or there is anything else you wish to communicate on the long scale in between these two extremes, please do not hesitate to contact the author:

(c) 2019, 2020 by dbj at dbj dot org

Content of this repository is licensed under the License DBJ