jeudi 26 mars 2015

How many :attr_accessor are too many for a class?

How many :attr_accessors 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