Difference between proxy template and virtual proxy template

I still knew about the proxy server template and recently read an article that says that a virtual proxy server is mainly used to delay the process of creating an object that uses memory intensively, thereby speeding up the application.

But after reading this article, it looks like the proxy template and virtual proxy template are the same thing. Am I right or am I misunderstood?

+7
source share
3 answers

There are different types of proxy templates. Virtual proxy is one of them. Others (from GOF) are a proxy protection server, a remote proxy server, and a smart directory. From GOF:

The remote proxy provides a local representative for the object in a different address space.

Virtual proxy creates expensive objects on demand.

The security proxy controls access to the source object. Security proxies are useful when objects must have different access rights.

A smart link is a replacement for a bare pointer, which performs additional actions when accessing an object

+7
source

In the book of GoF design patterns, several types of proxies are mentioned, one of which is a virtual proxy (which creates expensive objects on request).

Other proxies include a remote proxy (which provides a local interface for the object in a different address space), a security proxy (which processes access rights), and an intelligent link (which performs additional actions when accessing the object).

Thus, although virtual proxies are definitely proxies, not all proxies are virtual.

0
source

We can use the virtual proxy template in case of creating a custom camera .

Think about whether the β€œ3-4 clicks” option is on the capture_image page, creating a camera object every time we click on capture_image because it takes time to initialize the surface view (the view is used to create the camera in android). Thus, we can use the Virtual Proxy Pattern in this case to use the same instance from time to time and destroy this camera object when the view is destroyed.

0
source

All Articles