Loading...

Flexible Design with the Decorator Pattern in Rust: A Deep Dive | Advanced Rust Part 8

3,290 views 172________

#rustlang #softwarearchitecture #softwaredevelopment

Watch the rest of this series:    • Advanced Rust  
New to Rust? Check out my fundamentals series:
   • How to become a Rust Developer  

Decorators are an amazingly elegant way of introducing flexibility to your code without changing existing functionality. In this video, we will see a prime situation in which attack moves for a game can be layered beautifully with the decorator pattern, all while increasing modularity, readability and testability.

Find me elsewhere:
🐘 Mastodon: https://mastodon.social/@GreenTeaCoding

00:00 Intro
00:50 Introductory example
02:43 Naive attack extension
04:05 Problems of the naive extension
06:05 Decorator pattern
10:13 Applying decorators to our example code
12:19 Static vs dynamic dispatch
14:13 Visitor vs decorator pattern
15:00 When to use decorators
15:35 Typical use cases

Find this code on GitHub: https://github.com/Thodin/rust-decora...

コメント