has
Posts: 15
Nickname: has
Registered: Nov, 2004
|
|
Re: Which Part of "No XML" Don't You Understand?
|
Posted: Feb 1, 2006 5:21 PM
|
|
Guido wrote: > Anyway, I don't want a DOM manipulation tool either, because it will end up creating a pretty tight coupling between the HTML and the Python code manipulating it -- probably tighter than for Cheetah/Django/etc. style templates.
You misunderstand the intentions of DOM-style templating (or one of them anyway). The point is to separate presentation code from presentation markup, whereas with macro-style engines presentation code is embedded in presentation markup. The level of coupling, however, is unchanged: it's tight in either case.
Now, what DOM-style systems do *not* do is *enforce* loose coupling between presentation code and model code; they leave that choice entirely at the *developer's* discretion. Whereas most macro-style templating systems enforce loose coupling between presentation code and model code simply because each is created in a completely separate context - in many cases they're not even written in the same language - with only limited connectivity provided between the two.
This is where the confusion arises, as casual onlookers forget that the distinction between presentation and model logic is a *conceptual*, not physical, one. Now, you can argue the virtues of bondage-and-discipline vs. do-as-you-like environments all day (in which case the respective Java and Lisp camps are that-a-way...), but ultimately a bad programmer will manage to write badly structured code in any environment, while a good programmer is completely capable of writing well structured code in either.
To quote myself from the previous comment thread:
"""A good comparison is to the View and Controller layers in Apple-style MVC.
In Apple MVC, the View layer consists solely of graphical widget objects, assembled live and stored in serialized form (.nib) using Interface Builder, and the Controller layer contains the glue code that pulls data from the Model layer and inserts it into the View objects.
With DOM-style templating engines, the tagged HTML file is analogous to the .nib file, the templating engine = the AppKit framework that turns this data back into live objects, and the Python code that manipulates these objects = the Controller layer."""
I think that sums it up the architecture pretty well, and given the frequent praise that developers heap on 'the Cocoa way', who am I to argue? :) (In fact, back when I designed HTMLTemplate, this is where I stole most of my influences from.)
Personally speaking, I've done Cocoa GUI programming for a number of months and DOM-style templating for the last few years and in both cases I have absolutely no problem maintaining loose coupling between my presentation and model logic whenever I want to. The whole "X causes tight coupling" is an absolute canard in every case where X != "early Fortrans", "early BASICs" or "crap programmers"; and since nobody still uses the first two that kinda narrows it down a bit. ;p
HTH
|
|