Welcome Guest, Not a member yet? Register   Sign In
Should data be manipulated in the controller or is it "View"'s job
#3

(This post was last modified: 08-05-2016, 11:02 PM by PaulD.)

I think Jay Adra is correct generally, but in your particular example on date sorting, it is just as easy to send all the data in a single array, and have a little check that on date change put new title and carry on. A small bit of logic in the view can save a lot of hassles otherwise. I can't see any advantage to doing array manipulations within the controller or a library just to group out the results like that.

However, I suppose it depends on the complexity of the real data and what you are allowing users to do with it, and what you are doing with the page in the future. For instance will it always be a simple list of dates, or will you be doing further manipulations, like onclick revealing a panel showing more match details etc.

Generally, I agree that manipulations should be done in controllers or libraries, but in similar cases to your example, I think it might be a bit too puritan to insist that every tiny bit of logic (in this case for date separation), a line or two at most of simple code, should not be in the view, particularly since that logic is purely view related.

But, if you are going to need a similar list on multiple pages/locations then a small library routine to sort a general array into a more easily looped array for that type of list view might not be a bad idea either.

So I suppose I am saying it depends.

Best wishes,

Paul.
Reply


Messages In This Thread
RE: Should data be manipulated in the controller or is it "View"'s job - by PaulD - 08-05-2016, 11:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB