Saturday, October 26, 2013

Downside of Law of Demeter

Author indicates pass through methods (or new parameters added just to pass through?) are a necessary evil of LOD:

The downside is a number of "pass through" methods that do nothing but forward the message to the next child object... Like many OO guidelines, it's probably impossible and impractical to follow this one 100% of the time. The balance between spreading knowledge and adding overhead is a judgment call but I generally vote for more encapsulation until the overhead becomes too painful. 
http://www.ccs.neu.edu/research/demeter/demeter-method/LawOfDemeter/LawOfDemeter.htm