aspose 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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Books » Bunkhouse Porch
Reply 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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Head First Design Patterns - Principle of Least Knowledge
 
Similar Threads
Design Patterns...
Tight Coupling
Head First Design Patterns
OO design question?
Object Oriented Design Principles