User Tools

Site Tools


caching:ex2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
caching:ex2 [2008/10/07 13:51]
bdefrain
caching:ex2 [2008/10/07 14:25]
bdefrain
Line 12: Line 12:
  
 A correct implementation should pass the tests of suite ''tests.BoundsConstantCache''. A correct implementation should pass the tests of suite ''tests.BoundsConstantCache''.
 +
 +When done, remove the aspect from your build path before continuing with the next part.
  
 ===== Using several aspect instances ===== ===== Using several aspect instances =====
Line 17: Line 19:
 Imagine that a ''Group'' is [[wp>Serialization|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. Imagine that a ''Group'' is [[wp>Serialization|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.+To avoid this, write a new version of the above aspect that does not change the fields of the ''Group'' class.
  
 <note tip> <note tip>
Line 24: Line 26:
  
 A correct implementation should also pass the tests of suite ''tests.BoundsConstantCache''. A correct implementation should also pass the tests of suite ''tests.BoundsConstantCache''.
 +
 +When done, remove the aspect from your build path before continuing with the next part.
 +
 +===== Reusable caching aspect =====
 +
 +A //reusable// caching aspect seems very useful. Create a generic caching aspect from your previous result by extracting at least:
 +
 +  * The type of the cache value: i.e. ''Rectangle'' should not be hardcoded, use a type variable instead
 +  * The operation being cached: i.e. ''Group.getBounds()'' should not be hardcoded, make this pointcut abstract
 +
 +Then reimplement your solution using this generic caching aspect. The new implementation should still pass the tests of suite ''tests.BoundsConstantCache''.
  
 ---- ----
  
-Keep your aspect active and continue with [[caching:ex3|Exercise 3]].+Keep the last of your caching aspects active and continue with [[caching:ex3|Exercise 3]].
caching/ex2.txt ยท Last modified: 2021/02/05 13:51 (external edit)