This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Long ago we all figured out how superior it was to move stylistic information out of the markup and into CSS styles. Abominations like the <font> tag were deprecated in HTML 4, and HTML 5 goes further to eliminate all such stylistic markup from HTML.
But even though we separate style from markup, it's still very common to see behavior mixed with the markup.
Typically, the script is all sequestered into <script> blocks in the <head> and document ready handlers (described here) are used to initialize the page.
This keeps everything neat and tidy, and it's easy to know where to look for the behavioral aspects of the page.
Also i guess this is derivated from doing separation of concerns, for instance this sounds like the controller(the behavior of the view) to me, but i may be wrong, maybe it could be like the model(depending on the purpose of the behavior of course...)... not sure exactly... what do you think...?
Originally posted by Bear Bibeault: I don't think this technique directly maps to the C or M of MVC, but it is an off-shoot of the principle of sequestering things logically and reaps many of the same benefits.
It's more similar to the separation of concerns that we see in HTML/CSS (which is accepted gospel at this point). Separating behavior from markup is the next, cleaner step after moving style out of markup.
And it has the same benefits of making your behaviors more maintainable (you can have a set of behaviors that are defined by selectors which work across your site, just like CSS).