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

So you're advocating copy/paste style coding, and telling us it is less buggy?

Seriously? And without some extensive explanation?

What about the studies showing number of bugs is proportional to lines of code? Your way adds more lines of code.



No, I'm saying that putting common code in a separate method is not necessarily -- as in, "as a logical result or consequence" -- less error-prone.

I'm not advocating cutting and pasting huge blocks of code everywhere, but a 1-line calculation duplicated in 4 spots is probably okay.


It probably is okay to duplicate a calculation 4 times, all other things being equal. At the same time, I'd say it's probably a sign of other problems. If you need to reuse a calculation, that calculation is part of your application's domain (using the term loosely) and should be represented there, rather than being embedded inside scenario-appropriate parts of the system.




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

Search: