Search code examples
javadesign-patternsproxy-pattern

Is this over-eager loader object an example of a Proxy Pattern implementation?


I have a Java system that consumes an API. A few days ago, we started facing the following problem: the remote API was receiving too many requests from my system. Back in the system's early days, it was not a major concern, but little by little the system's performance was getting worse and worse, since my data was growing and I made multiple requests for each entity. I noticed many of the network requests I made were not really necessary, since the data was not updated very frequently. So, I implemented a class that, when my system starts, makes an over-eager loading of all the remote API data. When I create/update an entity, I load it before any request is made. I treat deletion accordingly. And the remote API also notifies me when any change is made so I can stay updated even when this change is made outside my system.

What I really want to know is: is there any name for this practice? Any known design pattern ? I must say I've done a little research and I think it is a proxy pattern but, again, I'm not very sure (in fact, most of the design patterns look very similar), and I'm not really that much into design patterns.


Solution

  • I would call it a Cache System to what you implemented. Not sure if there is a dessign pattern for this though.

    Also, the fact that the remote API notifies you when any change is made, might have been done using the observer pattern.