<div dir="ltr">On Wed, Oct 1, 2008 at 7:06 PM, David Chelimsky <span dir="ltr">&lt;<a href="mailto:dchelimsky@gmail.com" target="_blank">dchelimsky@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div><br>
</div>Au contraire! You&#39;re comparing apples and cadillacs here. Demeter is<br>
about encapsulation. Interfaces are about abstraction and structure.<br>
Completely different animals.</blockquote><div><br>Interfaces in that Java book and LOD in this topic were being supported by arguments of the form &quot;if you need to change things in the future...&quot; There are some practitioners for whom that&#39;s a valid argument, and there are others for whom it&#39;s an anti-argument. YAGNI is the latter. Doesn&#39;t make it right, but it does provide a way to evaluate each of these animals.<br>
&nbsp;<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Tracking down all of the trainwrecks in a system is not quite so<br>
simple. First of all, they are not guaranteed to look the same:<br>
<br>
trainer.animals.dogs.first<br>
<br>
vs<br>
<br>
t = trainer<br>
a = trainer.animals<br>
d = trainer.dogs<br>
dog = dogs[0]<br>
<br>
So when the design seems to want to categorize animals into domestic<br>
and wild, the first call has to be changed to<br>
trainer.animals.domestic.dogs.first. Good luck tracking down the<br>
second example</blockquote><div><br>In a statically-typed language, this would be trivial. In a dynamically-typed language using BDD, this would be caught by tests.<br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

Principles/guidelines like YAGNI and DRY and even the<br>
ever-threatening-sounding Law of Demeter are NOT LAWS. They are<br>
indicators. Red flag triggers. Red flags are *warnings*, not *errors*.<br>
</blockquote><div><br>We agree on that. See my recent post: <a href="http://www.nabble.com/Prepare-for-newbie-ness-to19516110.html#a19542377">http://www.nabble.com/Prepare-for-newbie-ness-to19516110.html#a19542377</a><br>
<br>In this case, we&#39;ve got two of these in direct conflict with each<br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
other, so which one wins? Gotta look at the costs and benefits of each<br>
and proceed wisely and *in context*</blockquote><div><br>I feel that YAGNI and LOD are at different levels of granularity. I use YAGNI and TSTTCPW in my daily life (which isn&#39;t to say that I always think they&#39;re the best approach). So I approach problems using those principles as my base. I don&#39;t ask myself a hundred times a day whether I should use a goto statement - I use structured programming as my base. Same with OOP, readable code, lack of commenting, etc. You can&#39;t approach everything de novo. So I apply YAGNI unless I see a compelling reason not to. The reason is that the &quot;costs and benefits&quot; of any approach are usually not obvious - especially when talking about the future.<br>
<br>///ark<br></div></div></div>