Imagine you have some Java code that does lots and lots of computation. All the time intensive calculations is performed by the class SlowCalculator which implements the interface Calculator:
Seem like an example how to not to do this. I recommend to read "Java concurrency in practice", there is an example how caching proxy code should look like.
Comments
Eugene Kuleshov replied ago:
Seem like an example how to not to do this. I recommend to read "Java concurrency in practice", there is an example how caching proxy code should look like.
sunitram replied ago:
why not do it this way?
stanasic replied ago:
Interesting, but dynamic proxying has been around for quite some time, since 1.3, so I would hardy call this amazing.
jimwhite replied ago:
This is a widely known technique called memoization.
http://en.wikipedia.org/wiki/Memoization
Just looked at the Java implementation link, and it is this same proxy method published five years ago.
http://www.onjava.com/pub/a/onjava/2003/08/20/memoization.html
Voters For This Link (7)
Voters Against This Link (3)