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
1
vote
1 answer

Dart, override many getters and setters in a DRY or synthetic way in a Proxy Pattern

Lets take this dart class: class Subject { String a; String b; String c; } Now I want to use it trough a Proxy, to manage lazy loading and synchronization. I want as well to have default values to use as placeholders while I'm loading the…
Pado
  • 1,497
  • 16
  • 28
1
vote
3 answers

Why is the proxy pattern so slow?

At least in java, the proxy pattern has a lot of overhead - I don't remember the exact figures, but when wrapping tiny methods the proxy takes something like 50 times as long as the wrapped method. This is, for example, why…
amara
  • 2,216
  • 2
  • 20
  • 28
1
vote
2 answers

Preprocessor with proxy design pattern

In the proxy section the Design Patter from the Gang of Four says: Overloading the member access operator isn't a good solution for every kind of proxy. Some proxies need to know precisely which operation is called, and overloading the member…
Ruggero Turra
  • 16,929
  • 16
  • 85
  • 141
1
vote
1 answer

C# - Allow Inheritance but Forbid Direct Use of Constructor

I want to allow inheritance, but forbid the direct construction of any of the inherited classes. Instead, I want to force the usage of the custom method New(). The goal is to make sure that every instance of inherited classes is a transparent proxy…
Mr.Yeah
  • 1,054
  • 2
  • 9
  • 21
1
vote
1 answer

I can not to forward exceptions from my proxy class

I have an interface: public interface ThirdPartySystemCaller { void sendRequest(String request) throws ThirdPartySystemException; } And implementation: @Slf4j @Service public class ThirdPartySystemCallerImpl implements ThirdPartySystemCaller…
ip696
  • 6,574
  • 12
  • 65
  • 128
1
vote
1 answer

What is the purpose of ContextWrapper (having a proxy for Context)?

According to the Android documentation, ContextWrapper is a "[p]roxying implementation of Context that simply delegates all of its calls to another Context. Can be subclassed to modify behavior without changing the original Context." I don't have…
Ellen Spertus
  • 6,576
  • 9
  • 50
  • 101
1
vote
1 answer

C# Monitoring closed-source classes and primitives for value changes

I need to be able to monitor a large number of objects for changes. In nearly any case, I could just use INotifyPropertyChanged and call it a day. However, my situation isn't as simple. The goal of my project is to create a simulation where any…
Haus
  • 1,492
  • 7
  • 23
1
vote
0 answers

How to use Proxy Apply trap?

Why my trap for withdraw function is not working? const checkingAccount = { owner: 'Saulo', funds: 1500, withdraw: function(amount) { this.funds -= amount; console.log('withdraw ' + amount + '. Current funds:' + this.funds); …
Saulo
  • 499
  • 1
  • 4
  • 16
1
vote
2 answers

ES6 Proxies - Is it possible to capture methods called upon a null object before they happen?

I'm working with an API that returns a schema for validating a form before users can submit their data. For example, the schema has a User class featuring an attribute called email. If there is an error, User.validators.getEmailErrors() returns an…
brogrammer
  • 804
  • 1
  • 12
  • 22
1
vote
1 answer

How to write a proper ES6 wrapper for something like sessionStorage

Hello I am wondering how to write a proper wrapper for something like sessionStorage. I could implement a class of my own and proxy through method invocation to the sessionStorage. For example with some quick pseudocode: class customStorage { …
Stephan-v
  • 19,255
  • 31
  • 115
  • 201
1
vote
0 answers

TypeScript mapped type for proxy

I want to achieve a conceptually simple thing: transform a map of functions that return any (or, for the sake of the example, number) to a map of functions that return void, while conserving the other type information. Expressed in code, I would…
DanielM
  • 1,106
  • 3
  • 17
  • 27
1
vote
2 answers

Apparent pollution with multiple Proxy objects for the same target

I'm attempting to create multiple Proxy wrappers for the same target object in JavaScript, with each individual wrapper having slightly different properties which affect how the wrapped functionality operates. These properties are assigned to and…
dmfay
  • 2,417
  • 1
  • 11
  • 22
1
vote
1 answer

Is proxy a good fit to create demo mode?

A lot of times we need a demo mode in certain projects which usually involves hardware with the purpose that the software can run/simulate without the hardware actually connected. The functions in demo mode simulate the hardware somewhat but don't…
zar
  • 11,361
  • 14
  • 96
  • 178
1
vote
1 answer

How to implement Proxy pattern in Objective-c (using runtime and other objc features)

Sometimes I need to implement proxy pattern in ObjC. I need it in cases were I create inner subject in runtime and do not want to move creation logic out from the proxy. Sometimes I use couple of objects inside the proxy, also I prefer use ARC to…
Andrew Romanov
  • 4,774
  • 3
  • 25
  • 40
1
vote
2 answers

Inner Proxy implementation in C++ class

I'm investigating cross platform library published by dropbox. following java code is from it. And i want to implement same thing in my Visual c++; First Look at java code public abstract class AsyncTask { public abstract void execute(); …
Knowledge Drilling
  • 986
  • 1
  • 8
  • 22
1 2 3
8 9