Say you want to render a table with five columns, but you want the order of the columns to be different depending on some specific parameter. This would be very easy to accomplish if the model sets the order. The view can then simply use a loop and create the table accordingly.

However, unless I have misunderstood things, we want to let the view handle how things are rendered (although I guess there may a gray area involved here in terms of what the view "should decide how to render")? It also feels ugly to let the model set formatting / order, but maybe this is another thing I might have misunderstood?

If the view is supposed to deal with the order of the columns, what is a good way to accomplish it (read: having to use a lot of if-statements and other ugly code in the view)?

  • 1
    Just to be absolutely clear, it sounds like you're asking about switching the arrangement of columns from displaying Adults, Children, Pets, Vehicles to Vehicles, Children, Pets, Adults; not changing from sorting the rows by ascending Adults to descending Pets, correct?
    – HABO
    Commented Jan 14, 2014 at 13:42
  • @HABO Yes, that is correct. Commented Jan 14, 2014 at 16:13

1 Answer 1


Split (conceptualy) your View into ViewView and ViewModel. In view model you will have things like order of columns, number of rows on page, current page, whether you are in edit mode. Simply things that you need to store, but does not make sense to store them in model (different view will not use them).

In what form view model is stored depends on view. It can be in session scoped variable on server (in web application), in hidden field (in web application), on mobile device (in mobile application communicating with server, so model itself is on server), just in different class (in standalone desktop/mobile app).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.