News for hackers. Stuff that matters.
Re:The bunny theory of code by 0xdeadbeefbabe on Monday May 18, 2015 @12:26PM (#9565289)
> I, for one, don't blindly copy and paste code

Yes, but blind to what? The coder is blindly manipulating symbols[0]. What if the code produces the artifact you desire? I'm not sure anyone really blindly copies and pastes. On the flip side, if you forget what you wrote in a month or two, how is that outcome different than copying and pasting in the first place?

[0] http://blog.airover.ca/2014/06/programming-blindly-manipulat...

Re:The bunny theory of code by barrkel on Monday May 18, 2015 @03:34PM (#9566400)
Someone sees this code somewhere:

    // this code accomplishes x
    foo();
    bar();
    frob(42);
They want to do x, and they copy the whole block, and perhaps modify the argument. They have only a surface understanding of what foo, bar and frob do, if any. They don't know if there is an order dependency; they don't know if the behaviour is specific to the situation where the code was copied from, or whether it applies (or not) to the place the code is copied to.

This is blind copy and paste. It is blind because it is not seeing through the symbols to the workings underneath. Functions, classes etc. as abstractions are useful, but they're leaky, and to write good code, you need to understand things at a lower level. At the very least, you need to know about implicit dependencies, time and memory complexity, and have a vague idea of the heft - the constant factor - of what you're putting into motion.

If it's a codebase undergoing continuous development, and foo / bar / frob are grouped together in more than one place, it's a smell. The code probably needs refactoring and restructuring, and all the calling points need adjusting.

This is just a more concrete example to get across what I'm talking about, since it seemed to be unclear. I don't have time to watch a video before replying, sorry.

Also the only way I forget what I wrote a month or two ago is if I've changed jobs, and then it's a willing forgetfulness. It takes many years for me to forget my code, for better or worse.