Handlers, Pipelines, Plugins, Rules, Mappers (22%) Flashcards
Which design pattern follows the handler chain ?
The chain of responsibility design pattern
What is the responsibility of each handler when its processing is complete ?
Calling the next handler in the chain or terminate the chain immediately
What is the sole entry point into a handler ?
The “Execute” method
Two handlers are part of the same handler chain if:
they both declare the same parameter and result object types
True or false.
As a best practice, all handlers should inherit from the HandlerBase class ?
True
Why do we need to decorate handlers with the DependencyName attribute ?
This allows the handler to be retrieved by name via the dependency locator.
Which method should continue an handler chain or break it ?
The the Execute method
What should be the last line of code of your handler to execute the next one?
return this.NextHandler.Execute(unitOfWork, parameter, result);
What should be the last line of code of your handler to break the handler chain?
return result;
What are mappers ?
Mappers are extension points of the Optimizely B2B Commerce platform.
What is the purposes of mappers?
Bridge the gap between the API presentation layer and the business logic layer (services) for both input and output.
Is it possible to inherit from Optimizely’s mapper classes ?
Yes
When you derive from a mapper class, where are you allowed to read additional information from the HTTP request and provide the information to the parameters object that will be used during the next handler chain ?
In the MapParameter method
True or false.
In a mapper, you should read information using the HttpContext directly in your handler chain extension?
False. The best practice is to collect all the information read from the HTTP request in the mapper and send it as properties to the parameters object for the handle chain.
Which method of a mapper allows us to intervene on the feedback of the handler chain (service result) and to pass it to the response object (API model) ?
The MapResult method