Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: A novice's thoughts on applying Demeter to extension code

by diotalevi (Canon)
on Nov 22, 2004 at 22:28 UTC ( [id://409761]=note: print w/replies, xml ) Need Help??


in reply to Re: A novice's thoughts on applying Demeter to extension code
in thread A novice's thoughts on applying Demeter to extension code

BrowserUK,
Whether it is valid or not to talk about an employee's manager's cost center isn't the point here. I could have use the employee's manager's email address as an example and it wouldn't have changed anything about my concerns regarding the Rule of Demeter. Could you re-read the question and consider in that light?

  • Comment on Re^2: A novice's thoughts on applying Demeter to extension code

Replies are listed 'Best First'.
Re^3: A novice's thoughts on applying Demeter to extension code
by BrowserUk (Patriarch) on Nov 23, 2004 at 07:10 UTC
    Whether it is valid or not to talk about an employee's manager's cost center isn't the point here

    Actually, it is exactly the point. At least as I see it.

    You are in a piece of code where you find yourself needing to access an attribute of an attribute.

    You are aware that by doing so, you are breaking the LoD.

    The question you asked is: How can you legitimise the need to break the LoD, by wrapping it into a method that conceals the fact that you are accessing the attribute of an attribute.

    But, if you re-read your post, you'll see that all of the methods you outlined, still access the attribute of an attribute; and so, still break the Law of Demeter.

    The problem lies not in the implementation that allows you to do it, but in the design that requires you to do it.

    My extended example was an attempt to show how such bad designs come about and why they are wrong.

    An attempt to show that any of the solutions you presented, or any solution thatcould be presented, that continued to allow you to apply the value of a Manager attribute, in the context of an Employee, would continue to break the Law of Demeter.


    Examine what is said, not who speaks.
    "But you should never overestimate the ingenuity of the sceptics to come up with a counter-argument." -Myles Allen
    "Think for yourself!" - Abigail        "Time is a poor substitute for thought"--theorbtwo         "Efficiency is intelligent laziness." -David Dunham
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://409761]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2024-04-24 00:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found