• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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