Skip to content

Commit aed840d

Browse files
committed
docs: update strangler
1 parent 10f3798 commit aed840d

File tree

1 file changed

+47
-5
lines changed

1 file changed

+47
-5
lines changed

strangler/README.md

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,61 @@ public class NewArithmetic {
113113

114114
The `NewArithmetic` class represents the system after the migration process. It only depends on the `NewSource` class. All methods now use the new source.
115115

116-
This is a typical example of the Strangler pattern. The legacy system (`OldArithmetic`) is gradually replaced by the new system (`HalfArithmetic` and `NewArithmetic`). The new system is developed incrementally, and at each stage, it strangles a part of the legacy system until the legacy system is completely replaced.
116+
Here is the `main` method executing our example.
117117

118-
## Class diagram
118+
```java
119+
public static void main(final String[] args) {
120+
final var nums = new int[]{1, 2, 3, 4, 5};
121+
//Before migration
122+
final var oldSystem = new OldArithmetic(new OldSource());
123+
oldSystem.sum(nums);
124+
oldSystem.mul(nums);
125+
//In process of migration
126+
final var halfSystem = new HalfArithmetic(new HalfSource(), new OldSource());
127+
halfSystem.sum(nums);
128+
halfSystem.mul(nums);
129+
halfSystem.ifHasZero(nums);
130+
//After migration
131+
final var newSystem = new NewArithmetic(new NewSource());
132+
newSystem.sum(nums);
133+
newSystem.mul(nums);
134+
newSystem.ifHasZero(nums);
135+
}
136+
```
119137

120-
![Strangler](./etc/strangler.png "Strangler")
138+
Console output:
139+
140+
```
141+
13:02:25.030 [main] INFO com.iluwatar.strangler.OldArithmetic -- Arithmetic sum 1.0
142+
13:02:25.032 [main] INFO com.iluwatar.strangler.OldSource -- Source module 1.0
143+
13:02:25.032 [main] INFO com.iluwatar.strangler.OldArithmetic -- Arithmetic mul 1.0
144+
13:02:25.032 [main] INFO com.iluwatar.strangler.OldSource -- Source module 1.0
145+
13:02:25.032 [main] INFO com.iluwatar.strangler.HalfArithmetic -- Arithmetic sum 1.5
146+
13:02:25.032 [main] INFO com.iluwatar.strangler.HalfSource -- Source module 1.5
147+
13:02:25.033 [main] INFO com.iluwatar.strangler.HalfArithmetic -- Arithmetic mul 1.5
148+
13:02:25.033 [main] INFO com.iluwatar.strangler.OldSource -- Source module 1.0
149+
13:02:25.033 [main] INFO com.iluwatar.strangler.HalfArithmetic -- Arithmetic check zero 1.5
150+
13:02:25.033 [main] INFO com.iluwatar.strangler.HalfSource -- Source module 1.5
151+
13:02:25.034 [main] INFO com.iluwatar.strangler.NewArithmetic -- Arithmetic sum 2.0
152+
13:02:25.034 [main] INFO com.iluwatar.strangler.NewSource -- Source module 2.0
153+
13:02:25.034 [main] INFO com.iluwatar.strangler.NewArithmetic -- Arithmetic mul 2.0
154+
13:02:25.034 [main] INFO com.iluwatar.strangler.NewSource -- Source module 2.0
155+
13:02:25.034 [main] INFO com.iluwatar.strangler.NewArithmetic -- Arithmetic check zero 2.0
156+
13:02:25.035 [main] INFO com.iluwatar.strangler.NewSource -- Source module 2.0
157+
```
158+
159+
This is a typical example of the Strangler pattern. The legacy system (`OldArithmetic`) is gradually replaced by the new system (`HalfArithmetic` and `NewArithmetic`). The new system is developed incrementally, and at each stage, it strangles a part of the legacy system until the legacy system is completely replaced.
121160

122161
## Applicability
123162

124163
* Use when you need to replace a monolithic or legacy system incrementally.
125164
* Ideal for scenarios where the system cannot be replaced in one go due to risk or complexity.
126165
* Suitable when you need to modernize parts of an application while ensuring continuous operation.
127166

167+
## Tutorials
168+
169+
* [Legacy Application Strangulation: Case Studies (Paul Hammant)](https://paulhammant.com/2013/07/14/legacy-application-strangulation-case-studies/)
170+
128171
## Known Uses
129172

130173
* Replacing a legacy monolithic application with a microservices architecture.
@@ -156,5 +199,4 @@ Trade-offs:
156199
* [Building Microservices](https://amzn.to/3UACtrU)
157200
* [Patterns of Enterprise Application Architecture](https://amzn.to/3WfKBPR)
158201
* [Refactoring: Improving the Design of Existing Code](https://amzn.to/3TVEgaB)
159-
* [Strangler pattern - Microsoft](https://docs.microsoft.com/en-us/azure/architecture/patterns/strangler)
160-
* [Legacy Application Strangulation: Case Studies - Paul Hammant](https://paulhammant.com/2013/07/14/legacy-application-strangulation-case-studies/)
202+
* [Strangler pattern (Microsoft)](https://docs.microsoft.com/en-us/azure/architecture/patterns/strangler)

0 commit comments

Comments
 (0)