5 ms·
I love how this is clearly a contextual recommendation. I'm not a software developer, but a data scientist. In pandas, to write your manipulations in this chai
by in9 5y ago
I love how this is clearly a contextual recommendation.
I'm not a software developer, but a data scientist. In pandas, to write your manipulations in this chained methods fashing is highly encouraged IMO. It's even called "pandorable" code
- mumblemumble 5y agoTBH, the only context where I've seen people express a strong preference for the non-chained option is under the charismatic influence of Uncle Bob's baleful stare. Otherwise, it seems opinions typically vary between a strong preference for chaining, and rather aggressive feelings of ¯\_(ツ)_/¯
- mywittyname 5y agoThe latter example (without the redundant assignments) is preferred by people who do a lot of line-by-line debugging. While most IDEs allow you to set a breakpoint in the middle of an expression, that's still more complicated and error prone than setting one for a line. I've been on a team that outlawed method chaining specifically because it was more difficult to debug. Even though I'm more of a method-chainer myself, I have taken to writing unchained code when I am working on a larger team. var frobnitzBuilder = Frobnitz.builder(); frobnitzBuilder.withPixieDust(); frobnitzBuilder.withMayonnaise(); frobnitzBuilder.withTarget(worstTweetEver); val frobnitz = frobnitzBuilder.build(); ...is undeniably easier to step-through debug than the chained version.
- mumblemumble 5y agoMight depend on the debugger? The main ones I've used also let me go through the chained version one at a time, including seeing intermediate values.