Strangler fig pattern: Difference between revisions

Content deleted Content added
m WP:GENFIXES on recently created page, added orphan, uncategorised tags
top: Fowler coined the name, but did not invent the technique
Tags: Mobile edit Mobile app edit Android app edit App full source
 
(19 intermediate revisions by 10 users not shown)
Line 1:
{{Short description|Computer science architectural pattern}}
In programming, the '''strangler fig pattern''' or '''strangler pattern''' is an [[architectural pattern]] that involves wrapping old code, with the intent of redirecting it to newer code or to log uses of the old code. Coined by [[Martin Fowler (software engineer)|Martin Fowler]],<ref name=":0" /> its name derives from the [[strangler fig]] plant, which tends to grow on trees and eventually kill them. It has also been called '''Ship of Theseus''' pattern, named after [[Ship of Theseus|a philosophical paradox]].<ref>{{ cite web |website=Understand Legacy Code |title=The Ship of Theseus to NOT rewrite a legacy system from scratch |first=Nicolas |last=Carlo |url=https://understandlegacycode.com/blog/ship-of-theseus-avoid-rewrite-legacy-system/}} </ref>
{{Orphan|date=January 2024}}
 
The strangler fig pattern tends to be used on [[monolithic application]]s, and it can be used toat migrate tothe [[microservices]].<refMethod name=":0" /> The pattern can be used at the(computer programming)|method]] level or the [[Class (computer programming)|class]] level.<ref>{{Cite book |last=Seemann |first=Mark |title=Code That Fits in Your Head: Heuristics for Software Engineering |publisher=[[Addison-Wesley]] |year=2022 |isbn=978-0-13-746440-1 |pages=228–237}}</ref>
In programming, the '''strangler fig pattern''' or '''strangler pattern''' is an [[Architectural pattern|architecture pattern]] that involves wrapping old code.
 
== Rewrites ==
One use of this pattern is during software rewrites. Code can be divided into many small sections, wrapped with the strangler fig pattern, then that section of old code can be swapped out with new code before moving on to the next section. This is much less risky and more incremental than swapping out the entire piece of software.<ref name=":0">{{Cite book |last=Newman |first=Sam |title=Monolith to Microservices: Evolutionary Patterns to Transform Your Monolith |publisher=[[O'Reilly Media]] |year=2020 |isbn=978-1-492-07554-7 |pages=79–97}}</ref>
 
The strangler fig pattern can be used on [[monolithic application]]s to migrate them to a [[microservices]] architecture.<ref name=":0" /><ref>{{cite web |last1=Behara |first1=Samir |date=12 December 2018 |title=Monolith to Microservices With the Strangler Pattern |url=https://dzone.com/articles/monolith-to-microservices-with-the-strangler-patte |access-date=12 March 2024 |website=DZone}}</ref>
Another use of this pattern is the addition of logging to old code. For example, logging can be used to see how frequently the code is used in production, which can be used to decide whether to delete low-usage code, or to rewrite high-usage code.<ref>{{Cite book |title=Five Lines of Code: How and when to refactor |publisher=[[Manning Publications]] |year=2021 |isbn=9781617298318 |pages=206–208}}</ref>
 
== Logging ==
[[Martin Fowler (software engineer)|Martin Fowler]] created this pattern.<ref name=":0" /> Its name derives from the [[strangler fig]] plant, which tends to grow on trees and eventually kill them.
Another use of this pattern is the addition of logging to old code. For example, logging can be used to see how frequently the code is used in production, which can be used to decide whether to delete low-usage code, or to rewrite high-usage code.<ref>{{Cite book |last=Clausen |first=Christian |title=Five Lines of Code: How and when to refactor |publisher=[[Manning Publications]] |year=2021 |isbn=9781617298318 |pages=206–208}}</ref>
 
== See also ==
The strangler fig pattern tends to be used on [[monolithic application]]s, and it can be used to migrate to [[microservices]].<ref name=":0" /> The pattern can be used at the method level or the class level.<ref>{{Cite book |last=Seemann |first=Mark |title=Code That Fits in Your Head: Heuristics for Software Engineering |publisher=[[Addison-Wesley]] |year=2022 |isbn=978-0-13-746440-1 |pages=228–237}}</ref>
* [[List of software architecture styles and patterns]]
 
== External links ==
* https://learn.microsoft.com/en-us/azure/architecture/patterns/strangler-fig
* https://martinfowler.com/bliki/StranglerFigApplication.html
 
== References ==
{{Reflist}}
 
 
{{Comp-sci-stub}}
 
{{Uncategorized stub|date=January 2024}}
[[Category:Software design patterns]]