How many :attr_accessor
s are too many for a class
, or, what is the "right" number of such methods (if there is such a thing as a "right number")?
So, as a trivial example, take
class Example
:attr_accessor :a, :b, :c, :d, :e, :f, :g, :h, :i, :j, :k
# instance methods here...
end
Obviously, sometimes a large number of such variables and the corresponding accessors are necessary (perhaps you'd see this in an ActiveRecord::Model
); but I'm looking for a decent heuristic to use when determining whether to refactoring based on the raw number of instance variables within a class.
Answers highlighting and/or summarizing articles, presentation, books, etc. on this design issue are much appreciated.
Aucun commentaire:
Enregistrer un commentaire