-
Book Overview & Buying
-
Table Of Contents
Design Patterns and Best Practices in Rust
By :
In this chapter, we will be discussing an anti-pattern: trying to design for object orientation in Rust. Anti-patterns are coding solutions that people commonly use in their code but that turn out to be unhelpful or even counterproductive. These problematic approaches may seem beneficial at first but ultimately lead to code that is difficult to maintain, inefficient, or prone to errors. What is unique here is that we will be discussing how a solid design pattern in one context can be an anti-pattern in a different one.
We will deal with common issues caused by treating Rust as if it were an object-oriented (OO) language such as Java or C++ and explore common errors from this kind of thinking. We will learn why OO design patterns cause issues when used in Rust and don't really work as they should. We will also look at situations where some OO techniques are helpful or even necessary.
First, we will dig into why Rust...