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
0
votes
2 answers

Method delegation to the parent in case of implementing proxies in JavaScript

In an example from Node.js Design patterns function createProxy(subject) { var proto = Object.getPrototypeOf(subject); function Proxy(subject) { this.subject = subject; } Proxy.prototype = Object.create(proto); …
arvin
  • 43
  • 6
0
votes
2 answers

Instantiate object defined as property in a PHP class as needed (lazy loading)

For the sake of simplicity, assume I have 2 classes, User and UserStatus, used in a Web application.
noisebleed
  • 1,299
  • 2
  • 12
  • 26
0
votes
0 answers

usage of Proxy Pattern of implementing operator overloading by return type?

From the answer, @James Kanze show an implementation of operator overloading by return type like this: class Proxy { My const* myOwner; public: Proxy( My const* owner ) : myOwner( owner ) {} operator int() const { return…
Chen Li
  • 4,824
  • 3
  • 28
  • 55
0
votes
3 answers

How to track a method result in Java

Briefly speaking, I am working on developing a system which is able to give you information about the results provided by the execution of a java program. I have considered the following problem, and I do not know if it is possible to solve it in…
csadan
  • 291
  • 1
  • 3
  • 13
0
votes
0 answers

Is it possible to determine in __getattr__ whether an attribute or method is accessed?

I'm aware that methods are just objects that can be accessed via getattr(obj, 'method_name'). Is the method does not exist, this will trigger obj.__getattr__(method_name). However, is it possible in the __getattr__ implementation to distinct whether…
danijar
  • 32,406
  • 45
  • 166
  • 297
0
votes
1 answer

proxy class constructor access

I have some troubles with a c++ project i started. I am trying to implement basic linked list and my attempt includes proxy class in the list class for representing single node. One of the list constructors can get single parameter and initialize…
Zarrie
  • 325
  • 2
  • 16
0
votes
1 answer

Scala Invocation Handler causes ClassCastException

I'm trying to implement a proxy pattern so that I can swap out an underlying instance dynamically under the covers when necessary along with an extension method to trigger the swap. I've implemented this in Java before, but I'm having trouble with…
pclem12
  • 449
  • 10
  • 23
0
votes
1 answer

proxy class in rvalue - how to implement assignment operator?

Suppose I have a simple vector class where elements are accessed through a proxy class. Vector class: class vec { public: vec(int len) { length = len; data = new double [len]; } proxy operator[](int i) { if (i >=…
Matt Hancock
  • 3,870
  • 4
  • 30
  • 44
0
votes
1 answer

Decorator pattern and generics

Regular interface: public interface IComputation { void Reset(); float GetValue1(); float GetValue2(); } Generic interface: public interface IComputation : IComputation where T : IComputation { T Proxy { get; set; } } Now for…
alhazen
  • 1,907
  • 3
  • 22
  • 43
0
votes
1 answer

Proxy pattern concrete class hiding implementation details

I have been reading about java proxy pattern and invocation handler and everywhere it is seen that the concrete class construction is available to the client. For example, //TwitterService service = (TwitterService) SecurityProxy.newInstance(new…
Adithya
  • 2,923
  • 5
  • 33
  • 47
0
votes
0 answers

How to force c# picture box to update its image after background worker has finished

My main goal is to load an image from a server and while the loading process is running I would like to show a placeholder instead of the real image. For reaching this goal I am using C# and Windows Forms. I have to use the proxy pattern and C#…
0
votes
2 answers

How to correctly expose API in a plugin system?

In the class diagram below you can see my current approach of the plugin/extension system. I want to offer the extensions an API for general/global things. But the exposed API should comprise just a subset of the actual functions of the referenced…
ManuelSchneid3r
  • 15,850
  • 12
  • 65
  • 103
0
votes
1 answer

With Proxy Pattern and Without Proxy Pattern

I have gone thru several examples but I didn't found any examples having displayed same example With Proxy Pattern and Without Proxy Pattern, Any one have a generic example ? by seen such example surely will understand do we really need Proxy…
Sanjeewa
  • 83
  • 2
  • 10
0
votes
1 answer

how to create a decorator proxy page in asp.net 3.5

I am trying to make this feature, and I'm really stuck. I have two applications that run on the same domain. and I need to have one application load pages from the other one inside it's own (the first) master page. I have full control of the code of…
Shany Tooper
  • 3
  • 1
  • 2
0
votes
2 answers

Good Constructor Design

In general, is it a bad idea to construct other objects within a constructor (I generally don't like it)? Suppose an object of type A needs an instance of type B. The instance of type B should be static, because I truly only want one copy of…
kakridge
  • 2,153
  • 1
  • 17
  • 27
1 2 3
8
9