3 ms·
Just my 2c: - the theme is to move the comments in the code by using variable names and function names that tell a story. Not a bad idea by itself, but nothing
by AdrianB1 6y ago
Just my 2c:
- the theme is to move the comments in the code by using variable names and function names that tell a story. Not a bad idea by itself, but nothing special there either.
- moving a simple one-liner arithmetic operation to a function that is stored somewhere else is a complexity increase that is hard to justify. Every line of code can be hidden behind a function, is that productive, acceptable and lean?
- not trying to be picky, but for free shipping I would prefer to do shippingCharge = 0 instead of that because that is what you want to do.
And a question: if the comments are out of the code (where they are mostly contextual), what kind of documentation is left behind for the support team? In my world the support team has encounters with code written 10 years ago by people no longer around, they know high-level what the code is doing, but the devil (bugs) is in the details.
- davethedevguy 6y agoI agree entirely that this isn't anything new, I hope I didn't imply it was. This is simply my own reflection on how to improve my coding style. > "Every line of code can be hidden behind a function, is that productive, acceptable and lean?" I've seen some advocate for that exact thing, but I certainly wouldn't go that far. I don't think we have to have one or the other, there's a middle ground in my opinion. If the code requires a comment to explain it, then maybe a well-named method/function is a better option. If the code is obvious in its own right (looping over a collection to add 1 to everything, to use a dumb example) then I don't think abstracting it is justified. I certainly don't have any objection to single-line functions to add readability per-se. (with the caveat that a compiler would produce the same result either way, or otherwise the performance of another function call isn't an concern. I'm talking purely about readability here)