Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Proxy Example #106

Closed
wants to merge 1 commit into from
Closed

Fix Proxy Example #106

wants to merge 1 commit into from

Conversation

danny-andrews
Copy link

The proxy class should be constructed the same way as the class it wraps. From this SO answer: "Proxy and Decorator both have the same interface as their wrapped types, but the proxy creates an instance under the hood, whereas the decorator takes an instance in the constructor." https://stackoverflow.com/a/7211706/2433572

As it stands, the proxy pattern is indistinguishable from the decorator pattern.

The proxy class should be constructed the same way as the class it wraps. From this SO answer: "Proxy and Decorator both have the same interface as their wrapped types, but the proxy creates an instance under the hood, whereas the decorator takes an instance in the constructor." https://stackoverflow.com/a/7211706/2433572

As it stands, the proxy pattern is indistinguishable from the decorator pattern.
@kamranahmedse
Copy link
Owner

Hey, thank you for the PR but I don't agree with you on this.

Although what you suggested is also a valid proxy, we can't say the one in the example wrong also. As according to the definition, proxy is just meant to mirror the functionality of a class into another class and it doesn't matter whether you create the instance inside the class or pass it to the class.

The up side of having the one that we have in the readme is you can use this proxy on top of any door implementing the DoorInterface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants