Skip to content

Commit f85840a

Browse files
committed
Work on Proxy blog post
1 parent 74a8bfd commit f85840a

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

_posts/2016-12-05-why-you-should-know-proxy-and-decorator.md renamed to _posts/2016-12-13-controlling-access-with-proxy-pattern.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
11
---
22
layout: post
3-
title: Why You Should Know Proxy And Decorator
3+
title: Controlling Access With Proxy Pattern
44
author: ilu
55
---
66

77
![Hexagonal Architecture]({{ site.baseurl }}/assets/hexagonal-architecture.png)
88

99
## Introduction
1010

11-
I will make an unusual arrangement here and describe two design patterns together. The Proxy and Decorator patterns are very similar to implement although conceptually they serve different purposes. Both of these patterns are extremely versatile and useful in many situations.
11+
One of the most useful and versatile design patterns is the classic Proxy.
1212

1313
## Proxy concept
1414

15-
Let's begin discussion with Proxy. Basically it wraps an object and acts as a proxy between calls to the object. At first thought it might not sound so useful but this simple concept is a great solution to many problems.
15+
Basically it wraps an object and acts as a proxy between calls to the object. At first thought it might not sound so useful but this simple concept is a great solution to many problems.
1616

1717
## Proxy example
1818

19-
To elaborate let's think of a simple example. In a fantasy land far away inhabited by creatures from hobbits to dragons mystic profession of wizards also exists. Wizards are known from their great magic but this power comes with a price. To upkeep and gain spell power the wizards must spend their time studying spellbooks and practising their spells. The best place in the neighborhood to study is the famous Ivory Tower built by the archmage Ivorious and it has become very popular among the wizards. However, to keep his tower tidy and not too crowded Ivorious decided to limit the amount of wizards that are allowed to enter simultaneously. He cast a protection spell on the tower that allows only the three first wizards to enter.
19+
To elaborate let's think of a simple example. In a fantasy land far away inhabited by creatures from hobbits to dragons the mystic profession of wizard also exists. Wizards are known from their great magic but this power comes with a price. To upkeep and gain spell power the wizards must spend their time studying spellbooks and practising their spells. The best place in the neighborhood to study is the famous Ivory Tower built by the archmage Ivorious and it has become very popular among the wizards. However, to keep his tower tidy and not too crowded Ivorious decided to limit the amount of wizards that are allowed to enter simultaneously. He cast a protection spell on the tower that allows only the three first wizards to enter.
2020

21-
<UML>
22-
23-
The class diagram shows the structure used to implement the Proxy pattern. WizardTower is the interface for all the towers and IvoryTower implements it. The plain IvoryTower allows everyone to enter but Ivorius has specifically cast a protection spell on it to limit the number of simultaneous visitors. The protection spell WizardTowerProxy also implements WizardTower but then it wraps IvoryTower. Now everyone wanting to access IvoryTower need to go through WizardTowerProxy.
24-
25-
<Code>
21+
The class diagram shows the structure used to implement the Proxy pattern. WizardTower is the interface for all the towers and IvoryTower implements it. The plain IvoryTower allows everyone to enter but Ivorius has specifically cast a protection spell on it to limit the number of simultaneous visitors. The protection spell WizardTowerProxy also implements WizardTower but then it wraps IvoryTower. Now everyone wanting to access IvoryTower needs to go through WizardTowerProxy.
2622

2723
## Types of proxies
2824

0 commit comments

Comments
 (0)