Question 57


1.1.2 Question

Multiple Choice

You have been given requirements for a dashboard page that will contain summary information from your order processing system in a single display table. However, this summarization needs to be done by combining data requests from the order system, the shipping system, and the accounting system. The dashboard page will be the only place you use this combined data. What is the best way to implement this require­ment?

  • A. Make the various data requests and compile the information in the controller for display.
  • B. Create an individual model for each of the data requests, and then create a view-specific model that calls those models and merges the data.
  • C. Create a model for the summary data and handle the various data requests within that model as well as the merging of the data.
  • D. Create an individual model for each of the data requests and then merge the data on the client side for display.

Answer:

B
Explanation
A. Incorrect: You should not perform any data manipulation in the controller.
B. Correct: You will have a better chance of code reuse if you break down the separate calls into their own models and then create another model to pull them together and compile them.
C. Incorrect: Although this would be a plausible way to implement the solution, it is not the best. If any other work came up that uses any of the calls within this model, you will either have to refactor the code to extract it at that point or have duplicate code.
D. Incorrect: The fact that this data can be merged into a single table display shows there is some intrinsic business worth to the information in this format. Merging on the client side goes against SoC considerations.