This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
title = "Decoupling Patterns in Ruby: Part 1 The Protocol Handler"
template = "page.html"
+++
## The Protocol Hander (The Controller)
Firstly, we have a __controller__, which has one job and only one job (ADD NOTE ABOUT SRP), to act as the programmatic interface for the request and response. Think of it as a primary function or an entry point for our script. Its context is
parameters provided by the user-agent, context provided by the protocol and method, and intent provided by the route. The question you should be asking yourself here is;
> Can I process the intent based on what has been provided by the request?
There are some things we must know here that represent our Buy-it-Now interface. The user we are acting upon and the product we are selling. At this stage of the request, we are only interested if those values are present and how to respond if those values are malformed or omitted.
The controller should not do any other work! The controller or entry point doesn't care if the user exists or the product is in stock; those concerns are for our service layer.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Create decoupling_patterns_in_ruby_protocol_handler_part1.md #2
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
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Create decoupling_patterns_in_ruby_protocol_handler_part1.md #2
Filter by extension
Viewed files
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing