I am mostly interested in Java, but I think it\'s a general question. Recently I\'ve been working with Arquillian framework (ShrinkWrap) that uses a lot of meth
The downside I have found of using method chaining is debugging the code when NullPointerException or any other Exception happens. Suppose you are having following code:
String test = "TestMethodChain";
test.substring(0,10).charAt(11); //This is just an example
Then you will get String index out of range: exception when executing above code. When you get into realtime situations and such things happen then you get at which line error has happened but not what part of chained method caused it. So it needs to be used judiciously where it known that data will always come or errors are handled properly.
It has its advantages too like you need not write multiple lines of code and using multiple variables.
Many frameworks/tools use this like Dozer and when I used to debug the code it I had to look through each part of chain to find what caused error.
Hope this helps.