[QUANTITY] and [OBSERVATION] data models: mutability

David Berry dsb at ast.man.ac.uk
Wed May 5 05:19:57 PDT 2004


Martin,

> > That's certainly a possibility. It would be particularly relevant I guess
> > for multi-threaded access to the Quantity. But on the other side of the
> > balance is the expense of object creation in most OO languages.
>
> It applies not just to multi-threaded access, but any occasion where
> more than one reference is held (I'm in a bit of a rush just now but can
> do examples for next week if need be).  The object creation overhead is
> a red herring at this stage!  It only really matters in tight, large
> loops where Quantity is likely to be inappropriately heavyweight anyway.

In single-threaded situations it should be possible to keep track of what
is happening to the Quantity. For instance, if you have two active
references to a single Quantity, and you pass one into a method which
changes the current Frame properties, then this method should advertise
this in its public contract. The calling code should then take account of
the possibility that the Frame properties may have changed when using the
either reference.

The rule should be that code never makes any permanent changes to an
object supplied by the caller unless it clearly advertises the fact in
its public contract. Then it is the responsibility of the caller to take
account of this contract.

Of course, all this becomes much more complicated in multi-threaded
situations. For which reason copying rather than modifying may be the way
forward.

David



----------------------------------------------------------------------
Dr David S. Berry    (dsb at ast.man.ac.uk)

STARLINK project		 |	Centre for Astrophysics
(http://www.starlink.ac.uk/)	 |	University of Central Lancashire
Rutherford Appleton Laboratory	 |	PRESTON
DIDCOT				 |	United Kingdom
United Kingdom			 |	PR1 2HE
OX11 0QX                                Tel. 01772 893733
                                             01257 273192



More information about the dm mailing list