[Tutor] OOP design - Law of Demeter
Harry Kattz
gibbs05@flash.net
Mon, 26 Mar 2001 09:27:31 -0600
Greetings All,
> For examnple you need to assign students to groups and
> move students from one group to another. You probably
> want to list the students in a group. Applying the
> principle that objects should "do it to themselves"
> (sometimes known as the law of demeter(sp?)) then
> students probably need a method to setGroup() and/or
> moveGroup(group). The group objects need a listStudents()
> method too.
Here's the Law of Demeter:
Do not refer to class C in 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.
Good luck,
Sam