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,[1] 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 a philosophical paradox.[2]

The pattern can be used at the method level or the class level.[3]

Rewrites

edit

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 less risky and more incremental than swapping out the entire piece of software.[1]

The strangler fig pattern can be used on monolithic applications to migrate them to a microservices architecture.[1][4]

Logging

edit

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.[5]

See also

edit

References

edit
  1. ^ a b c Newman, Sam (2020). Monolith to Microservices: Evolutionary Patterns to Transform Your Monolith. O'Reilly Media. pp.ย 79โ€“97. ISBNย 978-1-492-07554-7.
  2. ^ Carlo, Nicolas. "The Ship of Theseus to NOT rewrite a legacy system from scratch". Understand Legacy Code.
  3. ^ Seemann, Mark (2022). Code That Fits in Your Head: Heuristics for Software Engineering. Addison-Wesley. pp.ย 228โ€“237. ISBNย 978-0-13-746440-1.
  4. ^ Behara, Samir (12 December 2018). "Monolith to Microservices With the Strangler Pattern". DZone. Retrieved 12 March 2024.
  5. ^ Clausen, Christian (2021). Five Lines of Code: How and when to refactor. Manning Publications. pp.ย 206โ€“208. ISBNย 9781617298318.
edit

๐Ÿ“š Artikel Terkait di Wikipedia

List of software architecture styles and patterns

pattern Rule-based Saga pattern Strangler fig pattern Throttling Category: Software design patterns Software design pattern Software architecture Fundamentals

Ficus aurea

Ficus aurea, commonly known as the Florida strangler fig (or simply strangler fig), golden fig, or higuerรณn, is a tree in the family Moraceae that is

Second-system effect

Fowler, Martin (2024-08-22). "Strangler Fig Application". martinfowler.com. Retrieved 2026-01-26. "Strangler application pattern". microservices.io. Retrieved

Rewrite (programming)

design information from anything artificial Strangler fig patternย โ€“ Computer science architectural pattern Technical debtย โ€“ Cost of maintaining a low quality

Curtain Fig Tree

strangler figs such as the Curtain Fig Tree were considered to be wonders of nature. Strangler figs are epiphytes that develop when the seed of a fig

Ficus

Brazil Ficus aurea Nutt. โ€“ Florida strangler fig Ficus benghalensis L. โ€“ Indian banyan Ficus benjamina L. โ€“ weeping fig Ficus bizanae Hutch. & Burtt-Davy

Reproductive coevolution in Ficus

coevolutionary patterns in a community of strangler figs and pollinating wasps in Panama. Another possibility is the evolution of cheating. Where a single fig species

Ficus citrifolia

south to Paraguay. It is distinguished from the closely related Florida strangler fig (Ficus aurea) mainly by the finer veining in the leaves. Ficus citrifolia