Questions tagged [proxy-pattern]

A design pattern that provides a placeholder for another object to control access, reduce cost, and reduce complexity. One of the Gang of Four's structural design patterns.

A Proxy may

  • Provide a surrogate or placeholder for another object to control access to it.
  • Use an extra level of indirection to support distributed, controlled, or intelligent access.
  • Add a wrapper and delegation to protect the real component from undue complexity.

This is one of the Gang of Four's structural , first published in Gamma et al.'s book "Design Patterns: Elements of Reusable Object-Oriented Software".

More information is available on Wikipedia.

130 questions
2
votes
1 answer

Why bother using the proxy pattern when we can defer the expensive procedures in the RealClass?

I have been reading on Design Patterns recently, and there's something I don't understand about the Proxy Pattern. quote from the book: A virtual proxy creates expensive objects on demand. The ImageProxy described in the Motivation is an example…
du369
  • 821
  • 8
  • 22
2
votes
2 answers

JS Proxy Pattern

I use this code to override the window.alert function. The function replaces breaks by \r\n. It works fine in Firefox, but ofcourse not in IE. Im getting the error: Property or method not supported. (function() { var proxied = window.alert; …
Bram Verstraten
  • 1,414
  • 11
  • 24
2
votes
2 answers

Implementing Recursive Proxy pattern in C++11

Suppose we have some Foo object that allows: cout << myFoo[3]; myFoo[5] = "bar"; This calls for a proxy design-pattern (detailed by Scott Meyers here) But now let us suppose every myFoo[i] is also a Foo instance. myFoo[7] = Foo{...}; myFoo[5] =…
P i
  • 29,020
  • 36
  • 159
  • 267
2
votes
3 answers

Why does the proxy pattern require inheritance?

Looking at the UML diagram on wikipedia, both the proxy class and the subject class(es) implement the same interface. From what I understand, the purpose of the proxy class is delegation. This can be done via composition; the delegated class(es) do…
neverendingqs
  • 4,006
  • 3
  • 29
  • 57
2
votes
0 answers

Proxy pattern with the Stream class: actual Proxy or Decorator?

I'm a newbie that has just started diving in this world of Design Patterns by reading the Judith Bishop book "C# 3.0 Design Patterns". As an exercise at the end of the Proxy chapter, the author suggests to implement a custom class that "intercepts,…
Moz
  • 21
  • 2
2
votes
2 answers

Proxy Pattern - real subject not hidden from client

I was reading about Proxy on DoFactory and Wikipedia, and Stack Overflow, of course. Everything is clear, except Real Subject. On DoFactory, Proxy is defined as: Provide a surrogate or placeholder for another object to control access to it. …
Roman
  • 1,727
  • 1
  • 20
  • 28
2
votes
2 answers

Proxy pattern in Python

I have a lots of class implemented in my code. Now I realise that for each method invoked for all these classes I need to add a line: with service as object: So I'm trying to use the Proxy pattern to automatically do the job, this is my example…
nam
  • 3,542
  • 9
  • 46
  • 68
2
votes
2 answers

proxy pattern no suitable methods found to override? Help i'm not sure what just went wrong

This is all in the form... namespace Proxy_Pattern { public partial class Form1 : Form { public Form1() { InitializeComponent(); } double bankAmount = 1000.00; private void…
1
vote
1 answer

Proxy Design Pattern encapsulation solution?

I want to execute a function but before that , I want to verify the password. I choosed to use the Proxy Design Pattern. in words : create the Proxy class, send the password , and tell him WHAT FUNCTION TO EXECUTE if password is ok. the problem…
Royi Namir
  • 144,742
  • 138
  • 468
  • 792
1
vote
1 answer

How can Proxy and Facade design patterns be combined?

I have a third party library class Lib and an own LibProxy where LibProxy adds some caching before passign the control to Lib. This would have been textbook Proxy, but LibProxy also simplifies the interface to Lib. Which also makes it a Facade. What…
mlntdrv
  • 137
  • 1
  • 8
1
vote
2 answers

Issues using a delegateCall (proxy contract with Solidity) and using variables inside the delegate contract

I've written a simple proxy contract with solidity and I've got an issue with the variables inside the delegate contract. When I delegateCall, all my variables are equal to 0, except if there are constant. Is there any reason for that or am I…
Sam
  • 11
  • 4
1
vote
1 answer

How to make the JVM proxy the only one interface method?

public interface Action { void doSomething(); void dontProxy(); } For example with this interface, I just want the JVM to proxy the doSomething method. class DynamicProxy implements InvocationHandler{ private Action work; public…
1
vote
5 answers

What are ways of intercepting function calls or changing a function's behavior?

I would like to execute some code every time some functions in an object are called and finish executing. Object: { doA() { // Does A }, doB() { // Does B } } Is it possible to extend it, changing those functions so…
user5507535
  • 1,580
  • 1
  • 18
  • 39
1
vote
1 answer

Proxy Design Pattern: Association to the Interface or to RealSubject

I am currently learning the proxy pattern and have found two different implementations of it in two different books. Please see the links for patterns UML Diagrams as I cannot embed the pictures yet. Pattern 1 Pattern 2 My teacher says that Pattern…
PJ Drop
  • 50
  • 4
1
vote
1 answer

Access any site's service worker context/world/excution environment to proxy self.registration.showNotification via browser addon?

I'd like to create a browser extension that at its core proxies the registration.showNotification function to filter then based on rules set within the addon. Proxying window.Notification is trivial, but I'm having trouble even approaching the…
1 2 3
8 9