2020-12-16
1346
#vanilla javascript
Victor Jonah
30678
Dec 16, 2020 ⋅ 4 min read

What is railway oriented programming?

Victor Jonah I am a Software Developer with over three years of experience working with JavaScript and its frameworks. I currently work as a remote software developer for a tech agency.

Recent posts:

CSS typography in white on a vibrant red geometric background. Article will focus on the CSS backdrop-filter property and its various functions, including blur, grayscale, brightness, and drop-shadow.

How to use the CSS backdrop-filter property

Backdrop and background have similar meanings, as they both refer to the area behind something. The main difference is that […]

Oscar Jite-Orimiono
Oct 4, 2024 ⋅ 10 min read
6 AI Tools For API Testing And Development

6 AI tools for API testing and development

AI tools like IBM API Connect and Postbot can streamline writing and executing API tests and guard against AI hallucinations or other complications.

Frank Joseph
Oct 3, 2024 ⋅ 12 min read
Patterns For Efficient DOM Manipulation With Vanilla JavaScript

Patterns for efficient DOM manipulation with vanilla JavaScript

Explore DOM manipulation patterns in JavaScript, such as choosing the right querySelector, caching elements, improving event handling, and more.

Joe Attardi
Oct 2, 2024 ⋅ 8 min read
Integrating Chrome's New `Window.ai` API In A Vue App

Integrating AI features in Vue using Chrome’s `window.ai` API

`window.ai` integrates AI capabilities directly into the browser for more sophisticated client-side functionality without relying heavily on server-side processing.

Emmanuel John
Oct 1, 2024 ⋅ 10 min read
View all posts

5 Replies to "What is railway oriented programming?"

  1. In the last example, wouldn’t you still need to check isValidated before calling sendMail(), or maybe passing it in would be more in line with this design pattern? Or maybe I’m missing something, its late. 🙂

  2. Its is really unclear how the last example allows for decomposition of a single failure/sucess value to multiple firstname, lastname values

  3. Am I missing something? This seems like a basic overview of the Maybe Monad with respect to exceptions, but without any of the work shown. You haven’t given any mechanisms for ‘self-healing’, or dealing with the unhappy path at all, just that you CAN switch to one and that it’s better to write small functions than to throw all error handling into the main function.

  4. The principles of this “railroad” concept is nothing new. I was taught error handling like this over 30 years ago.

    One minor suggestion – rather than “success” or “failure”, the reality is that there is success, recoverable failure, non-recoverable unit failure, and non-recoverable app failure. The developer needs to determine if a failure is recoverable (e.g. login failure, connection timeout, etc.) or non-recoverable. If the latter, the developer needs to decide if the app is now unusable, or just one portion of it.

    Another suggestion – don’t just return success or failure. Include the appropriate enum flag, but also include in the return object details about what went wrong, such as all the error messages in the exception stack, snapshot values of runtime variables, what module, method, and line number the error occurred, etc., not only for logging, but for useful information for the user in a recoverable failure.

Leave a Reply