Applying the Law of Demeter

Peter Hansen peter at engcorp.com
Thu Dec 12 09:25:39 EST 2002


John Ochiltree wrote:
> 
> "Peter Hansen" <peter at engcorp.com> wrote in message
> news:3DF808BA.BCEFF9C8 at engcorp.com...
> > beno wrote:
> > > ClientData.Utilites() has method
> > > assembleGatewayData(paymentVehicle : int, **customerCreditInfo: dict,
> > > **gatewayData: dict)
> >
> > [snip other snippets]
> >
> > Uh, what language is that?  It's certainly not Python, so are you even in
> > the right newsgroup with this?
> >
> > Also, the description of the problem is unclear, and the terminology
> > used is confusing.  For example, "item X has method A which it
> > calls upon item Y".  That's paraphrasing what you said about
> > ClientData.Utilities() and how it does something with Payment.TheMoney().
> > In object-oriented programming, you wouldn't say that the first
> > thing "has" the method if it "calls it on" the second thing.
> > Do you mean the first thing calls the method that the second thing
> > has, or something else?
> 
> This is the first bit of this thread I've seen so I might be off the mark
> here. The 'language', Peter, is UML - The Unified Modelling Language. It is
> NOT a programming language. 

So this is a UML question so far, not a Python one... wrong newsgroup?  

(An side: my extensive but older experience with UML says it's a graphical
language.  Where did the textual description come from?  I don't think it's 
standard, but maybe I'm just out of date here.  My many UML books are all
very dusty at this point, as I've found UML to have far less value to me
than the hundreds of dollars I invested in it.)

> 'has a' and 'is a' are part of the notation for
> describing relationships. 

Sure, but they're still used incorrectly in the above, it seems to me.
If something "has a" method (and that's not how the UML "has a" relationship
works: I don't think "has a" is normally applied to methods), then it
can't "call that method on another item".  It could, perhaps, call
the method and pass the other item to it.  It could call the
method on another item if the other item "has" the method.  As
written, I don't think the phrase was meaningful, or at least it
was ambiguous.

> Also, I've never come across the 'Law of Demeter'. is it something like the
> succession of the priests of Diana :-) Please enlighten me.

Google is your friend :-) mentioning, among 2,490 others, this page:

  http://www.ccs.neu.edu/home/lieber/LoD.html

-Peter



More information about the Python-list mailing list