What is the exact difference between Adapter and Proxy patterns?

From here: Adapter provides a different interface to its subject. Proxy provides the same interface. You might think of an Adapter as something that should make one thing fit to another that is incompatible if connected directly. When you travel abroad, for example, and need an electrical outlet adapter. Now a Proxy is an object … Read more

What is copy-on-write?

I was going to write up my own explanation but this Wikipedia article pretty much sums it up. Here is the basic concept: Copy-on-write (sometimes referred to as “COW”) is an optimization strategy used in computer programming. The fundamental idea is that if multiple callers ask for resources which are initially indistinguishable, you can give … Read more

Differences between Proxy and Decorator Pattern

The real difference is not ownership (composition versus aggregation), but rather type-information. A Decorator is always passed its delegatee. A Proxy might create it himself, or he might have it injected. But a Proxy always knows the (more) specific type of the delegatee. In other words, the Proxy and its delegatee will have the same … Read more

How do the Proxy, Decorator, Adapter, and Bridge Patterns differ?

Proxy, Decorator, Adapter, and Bridge are all variations on “wrapping” a class. But their uses are different. Proxy could be used when you want to lazy-instantiate an object, or hide the fact that you’re calling a remote service, or control access to the object. Decorator is also called “Smart Proxy.” This is used when you … Read more