Separate Content, behavior and Presentation

Today the most dynamic thing in this world is the Web. These pages are made of no of things which are categories as presentation, behavior or functional and content. It would be very beneficial  to maintain all these artifacts loosely coupled.

Here is a simple example of keeping separate presentation and functional logic. In a sign in page , user has to enter login name which server will check for availability. Here is sample code

<input type="text" name="loginName" value="Enter Login Name" onblur="checkavailibility"/>

This tag invoke “checkavailibility()” function on blur event. To maintain loose coupling we can rewrite same logic in a java script file as

window.onload="initPage";
function initPage(){
    document.getElementById("loginName").onblur="checkavailibility"
}

Here initPage function get called on onLoad page event. This function access page element and set onBlur property . This way we can separate presentation and functional logic.

Comments

Popular posts from this blog

State Design Pattern by Example

Eclipse command framework core expression: Property tester

Composite Design Pattern by example