News for hackers. Stuff that matters.
Re:The Wrong Abstraction (2016) by barrkel on Sunday July 05, 2020 @04:51PM (#23741850)
I sometimes review PRs where people are encouraged (by other reviewers) to create new methods because there's a single line of code duplicated between two other methods. I don't think that rate of abstraction construction - and every method is another abstraction - is helpful for the health of the code, or its readability.
Re:The Wrong Abstraction (2016) by jiofih on Sunday July 05, 2020 @05:21PM (#23742115)
If that line of code deals with a particular piece of business logic, that should be consistent within the application, it’s a good thing.
Re:The Wrong Abstraction (2016) by Tainnor on Sunday July 05, 2020 @05:13PM (#23742047)
I can't judge that without more context. If this is just accidental duplication, it's pointless to abstract it away. But if it's a line of code that is necessary to deal with some gotcha of a particular library etc., it's probably good to extract and add an explanatory comment.
Re:The Wrong Abstraction (2016) by dave_sid on Sunday July 05, 2020 @07:58PM (#23743320)
“Accidental duplication” well said. Not enough people even consider this before deciding that they must remove the duplicate code. Will each duplicate section change for the same reason? If not then it’s not really duplicate code, it just looks the same.