The MVC is the object of somewhat of a religious ferver in the web development community. Many frameworks -- e.g. Zend Framework, CodeIgniter, etc. -- appear to me to be attempts at literal instantiations of the paradigm. Those frameworks have little appeal to me because they lock the developer into this single way of doing things. When the inevitable time comes that that way is not appropriate, the developer must resort to the framework's many workarounds, e.g. helpers or plugins (to plug the leaks? :)), extended classes, or hacks.
I wondered if the MVC is being used as it was originally intended so I researched it and read some of the creator's comments.
The MVC wasn't even called the model-view-controller; originally it was the model-view-editor. Additionally it was conceived by Trygve M. H. Reenskaug to solve the problem of network problems of the yards of the Aker Group in Norway. I think the idea got over-subscribed to by wannabe developer purists and their disciples, and as a consequence was bastardized into the impractacal forms we see depicted today around the internet.
Now, I admit, I haven't done complete dilligence on this research and so my conclusions may be premature or inaccurate. But when I see what I perceive to be serious inconsistencies between a implementations/interpretations of a model, I have to question whether the model as we know it is itself in its purest form.
For example, the Zend Framework, in which I'm no expert, apparently presupposes a single view delivered to a user at one time. If the model data must be aspected on the page, the developer has to use helpers or the ActionStack or some other hack to get the data on the page. I think this is a too-strict, too-literal, and consequently untenable, implementation of the MVC.
By contrast, the author of MVC appears to indicate multiple views presented can be the norm:
A user task may commonly be better performed with several Views present on the screen at the same time. The user will want to manipulate these Views through pointing at them, through selection in menus, or through some other means. Commands like selection typically apply to several Views at the same time. The purpose of an Editor is to establish and position a given set of Views on the screen, to coordinate them and to provide the user with a suitable command interface.
Some comments by Reenskaug lead me to wonder whether the MVC or MVE is applicable to web development at all:
Conversely, a view should never know about user input, such as mouse operations and keystrokes. It should always be possible to write a method in a controller that sends messages to views which exactly reproduce any sequence of user commands. http://heim.ifi.uio.no/~trygver/2007/MVC_Originals.pdf
How can we conclude that a PHP script can be an implementation of a "view" then? Is this what Reenskaug meant when he referred to the "perverted variants" of his model found in texts? http://heim.ifi.uio.no/~trygver/
Replace nested-if's with proper exception-handling
-
" Why handle exceptions separately:
■ Handling exceptions separately enables you to define the main logic of
your
code together.
■ Without the use of sepa...
2 years ago
No comments:
Post a Comment