Strangler fig pattern

From HandWiki
Short description: Computer science architectural pattern

In programming, the strangler fig pattern or strangler pattern is a software design pattern that involves wrapping old code.

One use of this pattern is 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.[1]

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

Martin Fowler created this pattern.[1] Its name derives from the strangler fig plant, which tends to grow on trees and eventually kill them.

The strangler fig pattern tends to be used on monolithic applications, and it can be used to migrate to microservices.[1] The pattern can be used at the method level or the class level.[3]

References

  1. 1.0 1.1 1.2 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. Clausen, Christian (2021). Five Lines of Code: How and when to refactor. Manning Publications. pp. 206–208. ISBN 9781617298318. 
  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.