File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Bunkhouse Porch and the fly likes Head First Design Patterns - Principle of Least Knowledge Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Books » Bunkhouse Porch
Bookmark "Head First Design Patterns - Principle of Least Knowledge" Watch "Head First Design Patterns - Principle of Least Knowledge" New topic
Author

Head First Design Patterns - Principle of Least Knowledge

Mike Himstead
Ranch Hand

Joined: Apr 12, 2006
Posts: 178
Hi,

I'm a little bit confused about a specific exercise regarding the "Least Knowledge" design principle. First of all, I do know what the principle means (I think ), what gives me a headache is one of the "Sharpen your pencil" tasks where one is asked to name classes that violate against the above principle. The classes are both called "House". While I understand the first issues (which is more or less the same mentioned in the chapter) the remarks about the second House class at the solutions page (page 272) puzzles me. My impression is that indeed nothing substantial did change, it looks more like "hacking our way around the principle".

Could anyone shed some light on this?
Dave Wood
bronco
Ranch Hand

Joined: Aug 02, 2004
Posts: 161
Originally posted by Mike Himstead:
Hi,

I'm a little bit confused about a specific exercise regarding the "Least Knowledge" design principle. First of all, I do know what the principle means (I think ), what gives me a headache is one of the "Sharpen your pencil" tasks where one is asked to name classes that violate against the above principle. The classes are both called "House". While I understand the first issues (which is more or less the same mentioned in the chapter) the remarks about the second House class at the solutions page (page 272) puzzles me. My impression is that indeed nothing substantial did change, it looks more like "hacking our way around the principle".

Could anyone shed some light on this?


Mike,

I think you and the authors agree. My interpretation of the comments in the solution is that they are saying "yeah, technically this no longer violates the PoLK (a.k.a. Law of Demeter), but all we really did was hack around the principle." In other words, it's really no better than it was before...just "fixed" on a technicality.

-dave


Co-Author of <a href="http://www.oreilly.com/catalog/jswing2" target="_blank" rel="nofollow">Java Swing</a><br />Co-Creator of <a href="http://www.sun.com/training/catalog/courses/CX-310-055.xml" target="_blank" rel="nofollow">SCJP 5.0</a> and <a href="http://www.sun.com/training/certification/java/associate_beta.xml" target="_blank" rel="nofollow">SCJA</a> exams
Mike Himstead
Ranch Hand

Joined: Apr 12, 2006
Posts: 178
Hello Dave,

thank you for sharing your thoughts.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Head First Design Patterns - Principle of Least Knowledge