First page Back Continue Last page Summary Text

Notes:


We should be able to see that the code is structured in such a way that if the object creations succeed then the dispose() method will be invoked on either the original or the replacement instances.
We've now reduced our assumptions to:
The clone() methods themselves are strongly exception safe.
Which seems reasonable. But beware: we have slyly introduced another assumption:
no exceptions are propagated by the dispose() calls.
I don't know what the client code can be expected to do in the event that an attempt to free resources fails – so I'm comfortable with this assumption. But we should be explicit about making it.
...
In addition to this we've also got a place where we can (carefully!) insert additional code that might throw exceptions – this may be needed if we have additional work to do within Whole as part of this method.
If you remember the earlier example if the Allocate-Use-Release motif then you will see the similarity, and may even spot a slight generalisation to this scheme – checking the value returned (for example: if (null != t1)...).