This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer (Exam 1Z0-830) Java SE 17 Developer (Exam 1Z0-829) Programmer’s Guide and have Khalid Mughal and Vasily Strelnikov on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Head First Design Patterns - Principle of Least Knowledge

 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
bronco
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Mike Himstead
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Dave,

thank you for sharing your thoughts.
 
reply
    Bookmark Topic Watch Topic
  • New Topic