How do Java programmers deal with long method chains? Sometimes one or two methods will have results that depend on the same long method chains being called on a several objects and it seems like overkill to ad开发者_如何学God methods to the class just to deal with one or two localized instances of long chains. In languages with first class functions I just usually define some kind of one off function in the block with the long method chain to factor some things out and shorten the method chain so what would be the equivalent in Java?
Indeed lack of closures makes this point thorny. I usually define a few private static method in the client class and place the various method chains inside these helpers.
精彩评论