On Wed, Aug 15, 2012 at 4:41 AM, Peter <[email protected]> wrote: > Not sure if you've ever worked on large classes in large Ruby/Rails projects > (unless you want to count "possible code smell" as an argument against this, > putting that aside for a moment) but if a "protected" or "private" block is > fairly large, it gets difficult to see what's going on without doing > "private :method_just_defined_on_previous_line" dozens of times (which to me > is a different kind of smell, but some consider it a valid style).
We had this question about ordering large number of methods the other day. My stance is that you should not have that many methods in the first place, i.e. it's a code smell. And I prefer grouping methods by visibility because that makes it much easier to understand the public API of a class - which is important for users of a class. Then you don't have the case of mixing public, protected and private methods. > Since a symbol is already created when a method is defined, and we are > dealing with a functional language (or one with functional aspects), I just > think it would be useful for a def to return something other than "nil", and > it would nicely dovetail with the fact that "protected" and "private" can > take symbol arguments. There are no extra costs involved. That seems like a fair analysis. Only that I am not sure about the symbol being created. But even if that would be an additional task the overhead would probably not be too big. >> Do note that your proposed "syntax" above is mostly achieved with 2 chars >> added: > > No, actually that only works for the case of 2 methods, one protected and > one private. If you have 10 protected methods and 10 private methods, the > situation quickly becomes more complicated. I think Ryan wanted to suggest to prefix *all* method definitions with the visibility. In that case it would work with more than two methods. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/ -- You received this message because you are subscribed to the Google Groups ruby-talk-google group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at https://groups.google.com/d/forum/ruby-talk-google?hl=en
