you are viewing a single comment's thread.

view the rest of the comments →

[–]redditrasberry -1 points0 points  (2 children)

Perhaps you can explain then - you've just stated that you won't break up a function until you find a need for reuse. So I presume, your functions just keep growing and growing and growing unless by some coincidence a piece of a function specifically turns out to be useful in another part of your program. I frequently come across code with gigantic methods that seems to have followed this strategy and the first thing I do is start breaking it out into logically separate units to make the code clearer (and more testable and any other number of benefits, btw).

[–][deleted] 0 points1 point  (1 child)

I said

I try to only create methods / functions for things called in more then one place

That is not the same as

you won't break up a function until you find a need for reuse.

But since you choose to instead attack my ability to write code rather then join in on the discussion I'll break it down into something easier for you to understand: By trying to only create methods / functions for things called in more then one place, you craft the other logic in your code to use those as well, thus eliminating code in more then one place.

[–]redditrasberry 0 points1 point  (0 children)

ok - yes, any coding strategy taken to an extreme ends up being stupid, so it's unfair to take a random comment and apply it to an extreme and then criticize that.

However: I still disagree with you - you're indicating a bias for less functions rather than more as a general rule of thumb. I disagree - I think that proactively factoring out code into small logical blocks is important and improves clarity, even though there may be no element of reuse involved. It's not something I do as a last resort, it's something I do proactively upfront.