3 ms·
One thing that was conspicuous for its absence was the "Law of Demeter." Is this not considered a good practice any more? It's trickier to use, because blindly
by oddthink 14y ago
One thing that was conspicuous for its absence was the "Law of Demeter." Is this not considered a good practice any more?
It's trickier to use, because blindly applying it can lead to immense classes, but I find it a useful thing to keep in mind.
- ollysb 14y agoThe rails delegate helper really helps with this, just declare which methods you want forward, optionally with a prefix. Sometimes a different name is more descriptive but this covers a large portion of the cases. class Foo < ActiveRecord::Base belongs_to :greeter delegate :hello, :to => :greeter end
- qu4z-2 14y agoMy friend-group has taken to calling it the Sometimes Helpful Suggestion of Demeter. It's sometimes helpful, but as you say, not really a "Law".