File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is strong law of demeter ?

 
Honggui Li
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Honggui
 
James Hobson
Ranch Hand
Posts: 140
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.softcomp.com/class7/demeter.htm http://www.cs.vu.nl/~eliens/online/oo/I/4/develop.html
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
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello:Mr. Hobson:
Thank you for your help. I appreciate it.
Have a nice day.
Honggui
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank God for Google.

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic