This is an old revision of the document!
Table of Contents
Caching: Constant cache
Using inter-type declarations
Task: Pass tests.BoundsConstantCache
.
Instead of making the (very) conservative approximation of getBounds()
from the previous part, write an aspect instead that remembers the return value from the first time getBounds()
has been called on a certain Group
, and returns that first Rectangle
for every subsequent call.
Group
class to store the cache value.
A correct implementation should pass the tests of suite tests.BoundsConstantCache
.
Using several aspect instances
Imagine that a Group
is serialized to some storage medium. If we use inter-type declarations to introduce a new field for the Group
class, then this field will be included in the serialized data of a Group
(so the schema changes). This is undesirable.
Therefore, write a new version of the above aspect that does not change the fields of the Group
class.
perthis
instantiation strategy to have one aspect aspect instance for each advised Group
object.
A correct implementation should also pass the tests of suite tests.BoundsConstantCache
.
Keep your aspect active and continue with Exercise 3.