News for hackers. Stuff that matters.
Re:Recombine to avoid naming when naming is hard by king_magic on Monday July 06, 2015 @12:36PM (#9840296)
Not every IDE is as helpful or forgiving for that kind of debugging. If you have things broken out, it's much easier to step through the intermediate states of expressions like that, and much easier to tweak when you need to fix something. Having everything together in One Expression To Rule Them All is a code smell, IMHO.
Re:Recombine to avoid naming when naming is hard by nerd_stuff on Monday July 06, 2015 @02:49PM (#9841320)
In the author's language, Clojure, it's trivial to print the intermediate value at every stage of a threading macro so you can watch your data as it transforms and pinpoint the problem, ex:

    (defn debug-it 
      [x] 
      (println x)
      x)

    (-> input-value
        debug-it 
        function1
        debug-it
        function2
        debug-it
        function3
        debug-it)
Debug-it could also take a custom message at each line if you wanted the output tagged with names/numbers.
Re:Recombine to avoid naming when naming is hard by KingMob on Monday July 06, 2015 @02:28PM (#9841132)
True, but Unnecessary Variables is also a code smell, and a worse one to me, because it increases cognitive load in larger functions.

In the toy function given, it doesn't really matter, but in general, I think that people should aim to code for clarity, not ease of debugging.

Re:Recombine to avoid naming when naming is hard by icebraining on Monday July 06, 2015 @12:44PM (#9840370)
Even when using C, you can use gdb to evaluate subexpressions at a breakpoint. I don't see why is it a code smell just because some tools are lacking.

I do think it's a smell if the expressions has side effects, but that's a different issue.

Re:Recombine to avoid naming when naming is hard by king_magic on Monday July 06, 2015 @01:21PM (#9840657)
I see it as a code smell precisely because some tools are lacking. I don't code for an ideal world where all tools and developers are perfect - personally, I take a practical approach and code for the real world.
Re:Recombine to avoid naming when naming is hard by icebraining on Monday July 06, 2015 @04:22PM (#9841936)
Fair enough, but then it's only a smell in languages lacking in those tools. In my real world, I can debug it just fine.