Comments on: Is it always a good idea to split long methods into smaller ones? An experiment. https://rubyclarity.com/2017/07/is-it-always-a-good-idea-to-split-long-methods-into-smaller-ones-an-experiment/?utm_source=rss&utm_medium=rss&utm_campaign=is-it-always-a-good-idea-to-split-long-methods-into-smaller-ones-an-experiment Refactorings of Ruby/Rails projects Thu, 13 Jul 2017 18:53:00 +0000 hourly 1 https://wordpress.org/?v=5.4.7 By: ledestin https://rubyclarity.com/2017/07/is-it-always-a-good-idea-to-split-long-methods-into-smaller-ones-an-experiment/#comment-9 Thu, 13 Jul 2017 18:53:00 +0000 https://rubyclarity.com/?p=412#comment-9 I don’t think it’s a problem at all, I never think whether a method is called by anything else. And if you really need to know that, there’s always ag(1).

]]>
By: ledestin https://rubyclarity.com/2017/07/is-it-always-a-good-idea-to-split-long-methods-into-smaller-ones-an-experiment/#comment-8 Thu, 13 Jul 2017 18:52:00 +0000 https://rubyclarity.com/?p=412#comment-8 TIL you can do it in Ruby. But I’d rather not do it like that. Just making some private methods would be fine, maybe inside a concern.

]]>
By: MadBomber https://rubyclarity.com/2017/07/is-it-always-a-good-idea-to-split-long-methods-into-smaller-ones-an-experiment/#comment-7 Thu, 13 Jul 2017 16:38:00 +0000 https://rubyclarity.com/?p=412#comment-7 > “… even though they won’t be called by anything else?.”

I’m almost embarrassed to suggest this structure …

def one
def two; puts 2; end
def three; puts 3; end
puts 1
end

]]>
By: ledestin https://rubyclarity.com/2017/07/is-it-always-a-good-idea-to-split-long-methods-into-smaller-ones-an-experiment/#comment-6 Fri, 07 Jul 2017 23:03:00 +0000 https://rubyclarity.com/?p=412#comment-6 Yes, but in this post I limited myself just to extracting methods. I wanted to experience and show what it’d be like to do just that.

]]>
By: Rodrigo Rosenfeld Rosas https://rubyclarity.com/2017/07/is-it-always-a-good-idea-to-split-long-methods-into-smaller-ones-an-experiment/#comment-5 Fri, 07 Jul 2017 16:22:00 +0000 https://rubyclarity.com/?p=412#comment-5 The first thing I would refactor in this method would be to add an early return when attributes are empty? and get rid of that long “unless” block:

return true if attributes.empty?

]]>