Proxy
Similar to the Decorator design pattern, the Proxy design pattern enhances an object’s capabilities. However, unlike a decorator that consistently follows instructions, a proxy might take a different route and behave differently when given a task.
In our earlier discussions about creational patterns in Chapter 2, where we explored working with such patterns, we already touched upon the concept of costly objects. These could be objects that rely on network resources or demand substantial time for creation.
Consider our scenario with the Funny Cat App, where we offer users daily doses of humorous cat images. On both our homepage and mobile app, users encounter an array of funny cat pictures. When they interact with these images, they’re presented in their full-screen glory.
The challenge lies in fetching these cat images from the network, a resource-intensive process, particularly if we’re dealing with images of cats that have a penchant for post...