Skip to content

Instantly share code, notes, and snippets.

@ecoologic
Last active December 17, 2019 23:22
Show Gist options
  • Save ecoologic/65a1910594bab8b3fbb790f6f03dbc95 to your computer and use it in GitHub Desktop.
Save ecoologic/65a1910594bab8b3fbb790f6f03dbc95 to your computer and use it in GitHub Desktop.

Design Patterns

  • Value: (read-only) does some math or manipulation with one input value, like a model, but for one value only
  • Presenter: (read-only) takes complex data, like different models, and provides extra presentation values, even HTML
  • Service: (mainly-write) Has a main method that writes data through delegation, and can expose the results as read-methods (eg: errors)
  • Query: (read-only) Joins different models and performs SQL queries on them, ideally through SQL views
  • Gateway: (read-write) LIB Wrap of an API (lib: favour primitives, don't depend on app)
  • Serializer: (read-only) Converts input to a string like JSON, CSV, PDF blob etc (prefer others)
  • Parser: (read-only) convert data from one format to another (prefer others)
  • Decorator: (read-only) extends an object with extra value otherwise written in a presenter (prefer others)

Why prefer others? In OO you should objects that represent your data, rather than actors that transform things, in general you can do this with a Value object

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