我有以下的服務類在Ruby中:在Ruby/Rails中使用長方法名是一個糟糕的實踐嗎?
class EnableUserMatriculations
def initialize(user)
@user = user
end
def call!
matriculations_that_current_user_is_matriculated_and_confirmed.each do |matriculation|
matriculation.enable!
end
end
private
def matriculations_that_current_user_is_matriculated_and_confirmed
# some logic to search user.matriculations that must be enabled
end
end
我想知道,如果名稱很長的方法是一個不好的初步實踐?
我不喜歡使用評論。
請給我這方面的意見。
「我不喜歡使用評論。」爲什麼?如果不好的做法,那就是不喜歡使用評論。 –
類名也不經常包含動詞。 –
我試圖遵循這些方法: (無評論)=> https://signalvnoise.com/posts/3250-clarity-over-brevity-in-variable-and-method-names (服務名稱與動詞)=> http://blog.sundaycoding.com/blog/2014/11/25/my-take-on-services-in-rails/ – Nonato