Review Handle class

Bug #1209828 reported by Ueli Hofstetter
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
JQuantLib
Fix Released
High
Richard Gomes

Bug Description

there are one or two a little bit suspicious aspects in the handle related classes..

1: why does Handle implement observable? in ql observers aren't registered at the Handle itself but at the link

2. why does linkTo(setLink) of the link class notify the observers of the observable and not the observers of the link?

3 ...

=============
Relationships
=============
has duplicate http://bugs.launchpad.net/bugs/jquantlib-333
child of http://bugs.launchpad.net/bugs/jquantlib-394

Tags: code-review
Revision history for this message
Richard Gomes (frgomes) wrote :

I've changed
   1. getLink(...) to currentLink(...) and
   2. setLink(...) to linkTo(...)

These changes will make classes Handle and Link look closer to QuantLib/C++ but there are still structural differences.

I've tried to removed "implements Observable" from class Handle and move all responsibilities to class Link but it didn't not work. A new tentative is needed after I figure out what would be the responsibilities of Link in this new scenario (I mean: in the original scenario defined by Quantlib/C++).

Revision history for this message
Richard Gomes (frgomes) wrote :

These comments where taken from the new implementation of Handle:
=================================================================

In QL/C++, Handle has operators which return the inner Link class, performing a call to currentLink() behind the scenes. This is pretty handy from the calling code because you can simply dereference a Handle and (like magic!) call methods from the parameterized class.

In Java we are obliged to explicitly call currentLink() in order to do the same thing.

The difficulty arises when we need to register Observers.

In the current implementation, we hide class Link from outside world and we only expose the Handle itself, which implements Observable. Doing this way, the calling Java code does not need to decide which object is really the Observer object because class Handle is responsible for hiding this implementation details from outside world and properly forwarding notifications to external Observers as expected.

Revision history for this message
Richard Gomes (frgomes) wrote :

done

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.