in reply to Testing objects that cache
Are they really the same?. The first thing you probably want to test is that the cached object and the non-cached object in fact do have the same "black box" behavior. Hand crafted optimizations have a nasty habit of breaking the very thing they are meant to help.
Does caching really improve things?The second thing to think about is what benefit is caching supposed to provide? Consider how you might put together some tests (or maybe benchmarks) that verify that the cached object really is an improvement over the non-caching object.
The boundaries of a black box are a matter of perspective. For the consumer of a business object API, caching is just another way of implementing the same API. However, if your caching is implemented as a service to be used by many objects, then those who use it will see the caching behavior itself as the boundary of the black box. They may not care whether you use arrays or hashes to implement it, but they will care that the promised algorithm does what you claim it does. For example, if you have an algorithm that says that cache members should be polled for last use timestamp each time an object is fetched, then you can test for compliance with that specific contract.
As for specific testing tools and practices, great question! I'm looking forward to the answers others have. It seems tricky to get right. Many of the things one might think first of testing for are transient effects. Furthermore, if you access objects to test the content of the cache you may end up disturbing the actual caching behavior. Yet another case of observation changing reality.
Best, beth
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Testing objects that cache
by Marshall (Canon) on May 16, 2009 at 18:58 UTC | |
|
Re^2: Testing objects that cache
by JavaFan (Canon) on May 15, 2009 at 14:15 UTC | |
by ELISHEVA (Prior) on May 15, 2009 at 15:46 UTC |