flâneur — a map of the web's best reading

Strategy in Rust / Design Patterns

refactoring.guru · 503 words · saved by 1 readers

Strategy is a behavioral design pattern that turns a set of behaviors into objects and makes them interchangeable inside original context object. The original object, called context, holds a reference to a strategy object. The context delegates executing the behavior to the linked strategy object. In order to change the way the context performs its work, other objects may replace the currently linked strategy object with another one. A conceptual Strategy example via traits. Functions and closures simplify Strategy implementation as you can inject behavior right into the object without complex interface definition. It seems that Strategy is often implicitly and widely used in the modern development with Rust, e.g. it’s just like iterators work: Buy the eBook Dive Into Design Patterns and get the access to archive with dozens of detailed examples that can be opened right in your IDE.

/ Design Patterns / Strategy / Rust Strategy in Rust Strategy is a behavioral design pattern that turns a set of behaviors into objects and makes them interchangeable inside original context object. The original object, called context, holds a reference to a strategy object. The context delegates executing the behavior to the linked strategy object. In order to change the way the context performs its work, other objects may replace the currently linked strategy object with another one. Learn more about Strategy Navigation Intro Conceptual Example conceptual Functional approach functional Conce

Explore this link on the map →

related reading