Method chaining makes for readable and reproducible code as you have demonstrated. There are however two major drawbacks if used without any additional steps.

The first is there is no validation evidence that each step undertaken in your long chain is correct. We have to trust you got it right as there are no intermediate steps to verify you met your intent.

The second related point is that it's difficult to debug to determine where an issue has arisen (assuming you spot the error in the first place).

To mitigate these issues, I have a version where the impact of each step is explored and if it behaves as expected I re-create it as a method chain. The process is the same as converting lines of python into a function. This means a debug notebook / script is available but more importantly the steps taken can be verified independently before the long chain is adopted.

Data Scientist and Chartered Aeronautical Engineer (MEng CEng EUR ING MRAeS) with over 15 years experience in the Aerospace, Defence and Rail Industry.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ashraf Miah

Data Scientist and Chartered Aeronautical Engineer (MEng CEng EUR ING MRAeS) with over 15 years experience in the Aerospace, Defence and Rail Industry.