Design patterns in Rust
Design patterns are "general reusable solutions to a commonly occurring problem within a given context in software design". Design patterns are a great way to describe some of the culture and 'tribal knowledge' of programming in a language. Design patterns are very language-specific - what is a pattern in one language may be unnecessary in another due to a language feature, or impossible to express due to a missing feature.
If overused, design patterns can add unnecessary complexity to programs (e.g., see AbstractSingletonProxyFactoryBean
). However, I think they are a great way to share intermediate and advanced level knowledge about a programming language.
So for these reasons, I have been thinking about design patterns in Rust, and in particular those that are unique to Rust or more common in Rust than other languages. I have started a pattern catalogue for Rust. It covers idioms (small, simpler design patterns), design patterns, and anti-patterns (patterns which you should strive to avoid). There's not a lot there at the moment. I hope to improve it over the next few months. I would love some help with that - if you like writing documentation and fancy describing some design patterns, please send a PR! There is a list of design patterns which need a description in the contents. If you know of other design patterns in Rust and want to add them, or want to improve some of the existing descriptions, that would be awesome.
I'll also be giving a talk about design patterns in Rust at the NOOL workshop at SPLASH/OOPSLA next week in Pittsburgh. If you're at OOPSLA, please come along!