Home > Java > JavaBase > The difference between proxy pattern and decorator pattern in java

The difference between proxy pattern and decorator pattern in java

王林
Release: 2020-01-15 16:52:12
Original
2294 people have browsed it

The difference between proxy pattern and decorator pattern in java

The proxy mode and the decorator mode look very similar. They both implement the interface implemented by the base object, and both store object references to the proxy/decorator in their own objects.

Definition of the decorator pattern:

Dynamically attach responsibilities to the decorated object to extend the functionality of the object. More flexible than inheritance. A typical design such as Java IO is a typical application of the decorator pattern.

(Free video tutorial sharing: java video tutorial)

Definition of proxy mode:

Proxy to other objects , to control access to the proxied object. Spring's proxy class generated for the business logic layer method mainly performs some transaction control, etc.

The difference between the two:

The decoration is responsible for extending functions, while the proxy mainly controls access.

Recommended related articles and tutorials: java introductory tutorial

The above is the detailed content of The difference between proxy pattern and decorator pattern in java. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template