3 ms·
It really depends. In my own software, I really appreciate when code is "clean" like that. I find it easier to keep in my head when methods are short. It also
by nerdponx 8y ago
It really depends. In my own software, I really appreciate when code is "clean" like that. I find it easier to keep in my head when methods are short.
It also depends on logic reuse. If you are now able to use the `check` method in other places, then I say it's overall a successful refactor.
- rdsubhas 8y ago> I find it easier to keep in my head when methods are short. How short? 100 lines? 10 lines? 1 line? "It depends" => i.e. discuss forever in PRs towards a one-way "shorter and shorter" ticket? More and more coders who join the project say the same thing, and reduce methods shorter and shorter and shorter, until it's dozens of classes with one method each having small lines like "twiddle-doo" and "fiddle-foo". Of course, now the method is easy to memorize, and supposedly it's "clean code" now. But the functional value and flow is just completely screwed up and can never fit in the head of anyone.
- nerdponx 8y agoI should clarify - I wouldn't accept a PR just to shorten a method for its own sake, if it's already written and working.
- zmmmmm 8y ago> I find it easier to keep in my head when methods are short I think that's true if "short" is measured in terms of internal complexity. I think each function should try to manage a small bite size amount of complexity that represents a reasonable level of cognitive load for a brand new person to reverse engineer. It could be quite a lot of lines of code if they are very simple ones, or it could be a one liner if it's super complex / obtuse.
- nerdponx 8y agoGood point. Yes, I meant logically short. Maybe logically compact is more apt.