aspose file tools*
The moose likes Beginning Java and the fly likes what is strong law of demeter ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what is strong law of demeter ?" Watch "what is strong law of demeter ?" New topic

what is strong law of demeter ?

Honggui Li

Joined: Aug 10, 2001
Posts: 26
Hello, everyone:
I got this question from my instructor,and i can't find the answer from the sun website. Please help me as soon as you can.
What is Strong Law of Demeter ? In each implementation of methods getArea() and calculateColor(),which form of Law of Demeter is broken?
class R
protected int width;
protected int height;
class FR extends Rectangle
private int color;
public int getArea()
return width * height;
public int calculateColor(float f)
return color * f;
I am looking forward to hearing from you.
Thanks in advance.
James Hobson
Ranch Hand

Joined: Aug 28, 2001
Posts: 140
Law of Demeter
Do not refer to a class C in a method m unless C is (the type of)
1. an instance variable
2. an argument of m
3. an object created in m
4. a global variable
Honggui Li

Joined: Aug 10, 2001
Posts: 26
Hello:Mr. Hobson:
Thank you for your help. I appreciate it.
Have a nice day.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Thank God for Google.

I agree. Here's the link:
subject: what is strong law of demeter ?
Similar Threads
CustomItem : Label dont Expand
How to fix error in Rectangle Class problem in Java?
Problem on interface
A Quadrilateral extend program
2 Liskov substitution principle questions