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:

Implementing Infinite Scroll In Next Js With Server Actions

Implementing infinite scroll in Next.js with Server Actions

Infinite scrolling in Next.js no longer requires external libraries — Server Actions let us fetch initial data directly on the server.

Rahul Chhodde
Apr 19, 2024 ⋅ 10 min read
Integrating Django Templates With React For Dynamic Webpages

Integrating Django templates with React for dynamic webpages

Create a dynamic demo blog site using Django and React to demonstrate Django’s server-side functionalities and React’s interactive UI.

Kayode Adeniyi
Apr 18, 2024 ⋅ 7 min read
Using Aoi Js To Build A Bot For Discord

Using aoi.js to build a bot on Discord

Explore how the aoi.js library makes it easy to create Discord bots with useful functionalities for frontend applications.

Rahul Padalkar
Apr 17, 2024 ⋅ 9 min read
Web Components Adoption Guide: Overview, Examples, And Alternatives

Web Components adoption guide: Overview, examples, and alternatives

Evaluate Web Components, a set of standards that allow you to create custom HTML tags for more reusable, manageable code.

Elijah Asaolu
Apr 16, 2024 ⋅ 11 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