Most of the blogs or tutorials or books have private methods at the bottom of any class/module. Is this the best practice?
I find having private methods as and when nece
As others have already pointed out the convention is to put private methods at the bottom, under one private class. However, you should probably also know that many programers use a double indented (4 spaces instead of 2) method for this. The reason is that often times you won't see "private" in your text editor and assume they could be public. See below for an illustration:
class FooBar
def some_public_method
end
def another_public_method
end
private
def some_private_method
end
def another_private method
end
end
This method should prevent you from having to scroll up and down and will make other programmers more comfortable in your code.