Plurrrr

Sat 23 Apr 2022

Rust traits and dependency injection

Dependency injection is one of my favorite design patterns to develop highly-testable and modular code. To apply this pattern, all you have to do is follow two simple guidelines:

  1. Separate object construction from usage. In practical terms: stop creating objects inside constructors and take those objects as input arguments.
  2. Use interfaces instead of concrete types as constructor parameters. In this way, the receiver remains agnostic to the implementation of those types and thus it becomes possible to supply different implementations.

Source: Rust traits and dependency injection, an article by Julio Merino.

Dune (2021)

A noble family becomes embroiled in a war for control over the galaxy's most valuable asset while its heir becomes troubled by visions of a dark future.

In the evening we watched Dune. Alice and Adam got tired and fell asleep. I liked the movie a lot; 8 out of 10.