Skip to content

Instantly share code, notes, and snippets.

@nicholasjhenry
Created November 14, 2012 05:56
Show Gist options
  • Save nicholasjhenry/4070557 to your computer and use it in GitHub Desktop.
Save nicholasjhenry/4070557 to your computer and use it in GitHub Desktop.
Deconstructing the Framework (Gary Bernhardt)

Design in the Small

  • Don't design a Model to be coupled to an API
  • Create a Service that talks to both your Model and the API

Service Wrapper Record

  • You have services, stateless objects that talk to the application
  • You have records, objects that talk to the database
  • And you have Wrappers, a thin class for a narrow interface to an API
  • Services can also talk to other Services

Garlic Pressing Rule

  • SRP Rule: A class should have one, and only one, reason to change.
  • Controllers tend to authenticate, authorize, wrap HTTP, manipulate models, manipulate databases (reload), query the database, present models, contain view content, create response content, route, choose content type, contain model logic...
  • "If you have a big thing, and you put it into a press to squeeze it out into a lot of little things, you'll have a lot of great little things that are better than the big thing.
  • Split the controller into various singular responsibilities.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment