News for hackers. Stuff that matters.
Re:On Comments in Code by ziml77 on Tuesday June 15, 2021 @03:52PM (#27520627)
Please no. Don't extract methods methods just to avoid using a comment. You end up making code more difficult to follow when you do that since you're now jumping somewhere else in the file and you're adding a lot of noise by having to pass the function's current state along as arguments to the new function.
Re:On Comments in Code by hackinthebochs on Tuesday June 15, 2021 @11:00PM (#27524404)
>by having to pass the function's current state along as arguments to the new function.

But then the state being read and mutated by a block of code is explicit. The alternative is having to inspect the code to determine if and what state is being manipulated. The more code in a functional unit, the harder this gets.

Re:On Comments in Code by nicoburns on Wednesday June 16, 2021 @02:19PM (#27531721)
If you're mutating variables then I'd agree that it might be best to encapsulate that in a function. But I'd argue that except for performance sensitive code, that's bad practice. The vast majority of code I write has 95% immutable variables. So even in a large function they'll typically be at most one or two mutable variables to keep track of (and very often zero).