Now I'm toward the middle of reviewing Chapter Five, "Attributes and Listeners", about to look at a list of the Eight Listener Types.
I gotta admit I'm rather enamored with Model-View-Controller (MVC) pattern, so I like to think about listeners from that perspective. I've even printed an MVC diagram as a kind of mental map for these, to decide, where would each kind of listener should go.
Because this is the deal with listeners within MVC: View listens to model changes, and Controller listens to the view's user gestures. But Model doesn't listen to anybody or have a handle on anything outside of itself; it's completely self-contained. Model is what the application would be if it didn't have any user interface.
My sense has been, according to the book, generally servlets are part of the controller and JSP's are part of the view. See Chapter 3, diagram on page 88. Attributes? Usually part of the model, I would think.. But if an attribute were a database connection, that makes it part of the controller's plumbing.
But from looking at these listeners, they don't seem to fit nicely into MVC. For example the servletContextAtributeListener. If context attribute were part of the model, the listener should be view. So, some JSP could be notified maybe. Context attributes wouldn't be part of the view would they? And who listens to the controller? Nobody. Well maybe this just goes to show, there are other places for listeners, outside of MVC. Or maybe I can say it's part of the controller, listening to other parts of the controller...
Thursday, January 14, 2010
Subscribe to:
Posts (Atom)