Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mock Question HFEJB page 426. Q4.

 
Simon Ingram
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello fellow ranchers,

The result of the f2.setBar(f1.getBar()); operation is that f1 has a broken link, b2 has a broken link and f2 is linked to b1. The linkages are UNIdirectional, meaning that Foo can access Bar but Bar cannot access Foo. This suggests to me that the operation b2.getFoo() should fail since Bar does not have a link to Foo (see page 391). Similarly b1.getFoo() should fail, even though, in this case, there is a link but it goes in the wrong direction. So I would say A is correct. In the book, it says B is also correct. Can anyone see why?

regards and thanks,
Simon
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe that the book is wrong, only A is correct.
 
Suman Sarker
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we think of it in this way -
after the code runs
step 1. f1.getBar() returns b1 and f1's link to b1 is broken.
step 2. f2.setBar(f1.getBar()) links f2 with b1. Now, b2 loses
its link to f2.

So, since f1 and b2 both get disconnected with their partners,
f1.getBar() = null and
b2.getFoo() = null but
b1.getFoo() = f2.

This is my understanding. Correct me if I am wrong.

Regards
Suman
 
Girija Siva
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Suman
I agree with Roger. The point is the relationship is Unidirectional. Bar does not have knowledge of foo. It can't access foo


The books errata does not state anything. Can Kathy or someone explain it how if the answer is both A & B

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic