Question 56


1.1.1 Question

Multiple Choice

You are designing an application in which a section of the main page will be populated by content from a third-party provider. You do not have control over the responsive­ness of the client or how much information will be returned with each request.

The call is to a RESTful service and will return the information formatted in Extensible Markup Language (XML). What is the best way to implement this application?

  • A. Design a model that handles the data call to populate the model. Create a partial view containing only this display area and put an asynchronous service call that returns this model in the partial view controller.
  • B. Put a synchronous service call into the main page controller.
  • C. Create a partial view containing only this display area and put a synchronous ser­vice call in the partial view controller.
  • D. Create a partial view containing only this display area and put an asynchronous service call in the partial view controller.

Answer:

A
Explanation
A. Correct: Because you do not have control over the responsiveness of the third-party provider and you do not know how much data might be returned from each call, you should wrap the call in the asynchronous framework. Providing the data in a strongly-typed model gives it more flexibility than working with the raw XML on the client side.
B. Incorrect: You do not know how long the call to the third party will take, and put­ting a synchronous call into the main page will not give any response until the call is completed.
C. Incorrect: You do not want to use a synchronous call in this case due to the un­known response time.
D. Incorrect: Although you can take this approach, it infers that you will manipulate the third-party response data in either the controller or the view. SoC recommends that this manipulation occur in a model.