Talk:Law of Demeter

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
Line 2: Line 2:
  
 
Just added an example --[[User:Kris Nicholson|Kris]] 00:28, 3 August 2008 (UTC)
 
Just added an example --[[User:Kris Nicholson|Kris]] 00:28, 3 August 2008 (UTC)
 +
 +
----
  
 
I spoke to Wal just after the lecture and we were talking about the Law of Demeter, and a situation arose which I have documented below in the UML diagram. It is possible that in this design you could say...
 
I spoke to Wal just after the lecture and we were talking about the Law of Demeter, and a situation arose which I have documented below in the UML diagram. It is possible that in this design you could say...

Revision as of 08:41, 12 August 2008

I started this page with a short description and basic solution...a couple of days ago --Kris 03:34, 1 August 2008 (UTC)

Just added an example --Kris 00:28, 3 August 2008 (UTC)


I spoke to Wal just after the lecture and we were talking about the Law of Demeter, and a situation arose which I have documented below in the UML diagram. It is possible that in this design you could say...

  car.getEngine.start()

But the Law of Demeter states that generally more than one dot in a line of code is a sign that the law has been broken.

Carengine1.jpg

We also talked about another way this design could be approached in order to satisfy the Law of Demeter. The below design would satisfy the law because the start() method in the Car class could look a little something like this...

start()
{
    engine.start();
}

Carengine2.jpg

Personal tools