On 24/04/13 01:10, wardrop (Tom Wardrop) wrote:
>
> Issue #8237 has been updated by wardrop (Tom Wardrop).
>
>
> Law of Demeter is blurry in Ruby. In Ruby, almost everything is a
> method call. Technically, (({5 + 5 + 5})) is a violation of the Law
> of Demeter if it's to be taken literally.

No it isn't.  The LoD talks about types, not individual receivers. 
You've only got one type there.  Getting more nitpicky, it's actually 
impossible to tell whether that's a violation without context because we 
don't know if Fixnum is already known to that scope, although core types 
are generally given a free ride.


> The fact that Ruby also
> uses plain-old methods as accessor further demonstrates the issues
> with applying the Law of Demeter to Ruby. In the right context, Law
> of Demeter could certainly be a helpful rule of thumb, but it can't
> be applied a some kind of avoid-at-all-costs global rule. I believe
> Ruby is too broad and generic to be considering laws like that of
> Demeter when designing language features.

Yep.  While LoD is useful, it's important to know a) when it shouldn't 
apply, and b) what it actually is.  It is *not* a polemic against method 
chaining.  I agree that it should not be a consideration in this case.

-- 
Alex