lab7-patterns

Lab #7. Design patterns

Oleksii Filonenko, PP-42

Facade pattern

// src/main.rs:10 // CLI subcommand is delegated to a submodule match app.command { Command::Init(options) => init::init(&options)?, Command::New(options) => new::new(&options)?, Command::Build => build::build()?, };

Single responsibility principle

// src/init.rs // Each module is responsible for a single use case, takes own parameter object, etc. pub fn init(Options { site_dir }: &init::Options) -> Result<(), Error> { // ... }

(almost) applicable to Rust code

  1. Each module (function + options struct) could be make into a Command, but according to YAGNI, I did not :)