Railway Oriented Programming (ROP) is a functional programming technique that allows sequential execution of functions, not necessarily synchronous. The key concept is that each function can only accept and return Container of either Success or Failure. Failure wraps Throwable type and Success can be of any type. Published by Tonje Krosby.
This concept is present but not promoted in Kotlin since Kotlin 1.3. The matter of fact Kotlin KEEP states that feature may change in the future. At the time of writing this blog post, Result
Example of functions that can have this paradigm and how to write adapters to those functions:
- Single track functions. Functions with no errors and no possible exceptions. See ComplexNumber and ComplexNumberResult examples.
- Dead-end functions. Functions which throw errors. Such as OutOfMemoryError or StackOverflowError. See HtmlParser and HtmlParserResult examples.
- Functions that throw exceptions. This is especially useful with IO operations. See DownloadPage examples.
- Supervisory functions. Functions which logs and supervise existing code, not necessarily return the result. See SentryLogin and SentryLoginResult examples.
Excellent read for all fans of functional programming![Read More]