Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Umbrella: Repository Content (Scope)/ TODOs #116

Open
5 of 57 tasks
simonsan opened this issue Jan 1, 2021 · 4 comments
Open
5 of 57 tasks

Umbrella: Repository Content (Scope)/ TODOs #116

simonsan opened this issue Jan 1, 2021 · 4 comments
Labels
C-needs discussion Area: Something that is not clear to everyone if it fixes something/adds valuable content E-help wanted Call for participation: Help is requested to fix this issue

Comments

@simonsan
Copy link
Collaborator

simonsan commented Jan 1, 2021

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

@simonsan simonsan added E-help wanted Call for participation: Help is requested to fix this issue C-needs discussion Area: Something that is not clear to everyone if it fixes something/adds valuable content labels Jan 1, 2021
@simonsan simonsan pinned this issue Jan 1, 2021
@burdges
Copy link

burdges commented Jan 1, 2021

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.

@simonsan
Copy link
Collaborator Author

simonsan commented Jan 2, 2021

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

Nice, for sure! 💯

@simonsan simonsan changed the title Umbrella: Design patterns Umbrella: Repository Content (Scope)/ TODOs Jan 6, 2021
@simonsan
Copy link
Collaborator Author

Today I discovered https://github.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

@pickfire
Copy link
Contributor

pickfire commented Apr 1, 2021

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
Labels
C-needs discussion Area: Something that is not clear to everyone if it fixes something/adds valuable content E-help wanted Call for participation: Help is requested to fix this issue
Projects
None yet
Development

No branches or pull requests

3 participants