Ashraf Miah
1 min readDec 26, 2022

--

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.

--

--

Ashraf Miah

CTO, Data Scientist & Chartered Engineer (MEng CEng EUR ING MRAeS) with over 20 years experience in the Aerospace, Rail & Energy Industry.