Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

you have this backwards: reusing code couples the code. copy+paste uncouples code

if you have two functions, they're not coupled. you change one, the other stays as-is

if you refactor it so that they both call a third function, they're now coupled. you can't change the part they have in common without either changing both, or uncoupling them by duplicating the code

(you often want that coupling, if it lines up with the semantics)



I meant code within the snippet is tightly coupled. You can't just cut the for loop in half and reuse half the logic.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: