NYCPHP Meetup

NYPHP.org

[nycphp-talk] the stale V in MVC web apps

Michael B Allen ioplex at gmail.com
Wed Mar 4 11:51:51 EST 2009


On Wed, Mar 4, 2009 at 10:49 AM, David Mintz <david at davidmintz.org> wrote:
>
> I've got users working collaboratively all day long on a set of database
> records. The view in front of them is frequently stale. A common old Web 1.0
> approach to solve this was to reload the page automatically every n seconds
> with a meta refresh. Nowadays we have xhr. Either way, my concern is as the
> W3C points out, an unexpected refresh can disorient users.

IMO the W3C doesn't know much about dynamic web content. The W3C
specifications are designed around displaying "documents" and not
"interactive applications". So if you want a site that looks something
like say, mmmm .... the W3C website, then you're gold. If not, you
need to look elsewhere for help.

> I have thought of displaying a thingy at page load time that says "reloading
> automatically in 5 minutes" and then updating via Javscript it to count
> down  4, 3, 2 and after maybe 30 seconds start counting off seconds, then
> update via ajax. The upside is they won't get (or at least shouldn't be)
> surprised. The downside is more clutter, potentially annoying and/or
> distracting. But I think you could put a discrete little timer thingy that
> ought not be too irritating.
>
> I understand the problem is so common that someone has coined "Asynchronous
> MVC."

IMO I don't think MVC really even applies to the web. V is supposed to
watch M which is updated by C thereby causing V to update only the
part of the display affected. So with HTTP being stateless, V can't
actively "watch" M and react independently to updates by C. I think
people wanted MVC to apply to the web so much they simply declared it
so and "poof" ... it was.

> What do YOU do about this sort of thing?

I think asynchronous JavaScript requests are used way too much but it
might be applicable in this case. The litmus test in this case I think
is to imagine that you just use a "Refresh" button. Then imagine
people working and think about how frequently the display will update
just in the course of doing that work and if those updates will be
sufficient to keep the wheels of workflow turning. If you do not think
it will be sufficient and you think that users will ultimately just
sit there literally hitting "Refresh" every 30 seconds all day long,
then you should think about adding asynchronous JavaScript to assist
with updating the records in the display.

Mike

-- 
Michael B Allen
Java Active Directory Integration
http://www.ioplex.com/



More information about the talk mailing list