How does everyone order their methods in a class?

# Alphabetical
def a; end
def b; end

# Importance
def business_logic; end
def utility_method; end

# Invocation sequence
def call

def called_first; end
def called_second; end


@shanecav mostly importance (or by I try to group related methods together), but often it's way too "random"…

@judofyr Nice. I'd like to order by importance or relatedness but I find those criteria are hard to determine in practice, resulting in random-ish ordering, so I stick with alphabetical.

I ask bc I'm working on a rubocop extension for ordering methods ( and want to see where the community is at. The cop currently only supports alphabetical ordering but I'd like to add config to check for ordering by invocation sequence.

Sign in to participate in the conversation

A Mastodon instance for Rubyists & friends