patterns icon indicating copy to clipboard operation
patterns copied to clipboard

Choose more descriptive and/or realistic examples than `foo-bar-baz`

Open mihsamusev opened this issue 3 years ago • 6 comments

Thank you for a great effort on the patterns book. An enhancement suggestion. There are many good examples in the book that help to relate the patterns and their application. However, in some places there are classic foo bar and baz examples that, yes, show the intended interaction that the pattern tries to achieve, but get completely decoupled from the application. I think overall useful book looses quality with those examples. Compared to the official rust book where language features are exemplified on relatable structs and functions from real life i think that should be the standard for examples.

Concrete suggestion select more descriptive example for:

  • Newtype pattern - https://rust-unofficial.github.io/patterns/patterns/behavioural/newtype.html
  • Compose pattern - https://rust-unofficial.github.io/patterns/patterns/structural/compose-structs.html

mihsamusev avatar Mar 09 '22 09:03 mihsamusev

Yes, I agree with you. PRs are welcome :)

marcoieni avatar Mar 09 '22 12:03 marcoieni

@simonsan Can you assign this issue to me ? I'm eager to create PR to fix it

Owen-CH-Leung avatar May 22 '23 12:05 Owen-CH-Leung

Sure :)

simonsan avatar May 22 '23 12:05 simonsan

Both examples have been fixed now, but there are more to go, I would keep this open as a more general issue.

simonsan avatar May 25 '23 13:05 simonsan

As someone who is new to patterns, I've found this book to be incredibly helpful, but I'm a bit puzzled about the 'Compose Struct' chapter compared to the 'NewType' pattern. Initially, when delving into the example code, I found it very similar to that of the NewType pattern. So, I thought 'Compose Struct' was about composing a struct using 'NewType' instances. Now I've come to realize that the 'Compose Struct' pattern is more about struct decomposition and borrowing each field independently rather than the composition through 'NewType'. So maybe removing the NewType from the example will be clearer.

mtfcd avatar Mar 01 '24 09:03 mtfcd