Created
June 27, 2011 15:23
-
-
Save joefiorini/1049083 to your computer and use it in GitHub Desktop.
Indent methods under private?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Blah | |
private | |
def method1 | |
end | |
def method2 | |
end | |
end | |
# vs. | |
class Blah | |
private | |
def method1 | |
end | |
def method2 | |
end | |
end | |
# vs. | |
class Blah | |
def public_method | |
end | |
private | |
def method1 | |
end | |
def method2 | |
end | |
end |
Indenting private section is good for huge classes where you can find some private method, trying to use it, and then realise that it is actually private. So I use #2 for small classes and #1 for huge classes with a lot of private methods.
#3 way seems very strange and meaningless.
I've always used 1 but at my current job they use 2 so I've switched to that for the sake of consistency. I don't feel strongly but prefer 1.
However, I really dislike 3 as it visually interrupts the scope of the class.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Who does #2 work for? https://www.youtube.com/watch?v=nmJKY59NX8o