January 28, 2013

Simplicity Despite of Technical Knowledge

Old Style Javascript


A web page is a simple concept to understand, and that is why it caught on so fast in the first place.

And our desires to interact with it are also simple.

Say, there are a number of thingies ("a", "b", "c", "d", and "e") on the page and I want to take some simple actions on them e.g. ( "touch", "drag", "mouse-enter", "mouse-move-away", "click", "focus" and so on ).

Thus, if I click "a" on the web page, I expect some reaction.
Thus, if I drag "b" on the web page, I expect some reaction, maybe the same or something different.

Very simple and very reasonable expectations.
But what did old javascript offer?

Your action: Click a submit button of a form
Your expected reaction: Check the value of a field/blank in the form

Then, you must code/write something long, verbose and ugly. You can verify this by reading any old javascript book.

My Style Javascript


I refuse to touch such smelly, messy stuffs. So, I did something like:


onClick="clicker('id1964')"     

onMouseOver="mover('id1')" 

onMouseOut="mouter('id1964')"  

onClick="displayText('id11', 'Khine 1980');"


/* KYAW TEST June 25, 2007 */

function loader() { alert("on load on body tag"); }

function unloader() { alert("on unload on body tag"); }

function blure() { alert("on blur on body tag"); }

function focuse() { alert("on focus on body tag"); }

function clicker(elemId) {
    var elem=document.getElementById(elemId)
    elem.style.color="red"
    alert("this box follow the link anyway!!!");  
}
function mover(textAreaName) {
    document.getElementById(textAreaName).style.visibility="hidden";
    alert("blah");  
}
function mouter(textAreaName) {
    document.getElementById(textAreaName).style.visibility="visible";    
}

function displayText(textId, mess) {    
    document.getElementById(textId).firstChild.nodeValue=mess; 
}

The function "loader" acts when something is loaded.
The function "focuse" acts when something is focused.
The function "mouter" acts when the mouse is outted.
And so on.

Does it take brains to write simply like that?

Let jQuery Beat Me But ...


As you can see in the comment lines, these were done in June 2007. At that time, I wasn't keen on javascript and so hadn't heard of jQuery and John Resig and his wonderful inventions and re-inventions.  Now with his marvellous library, to get similar effects, I write just 1 or 2 lines.

Conclusion


Insist on simple, reasonable stuffs as a discerning buyer, on behalf of your own customers.
Refuse to use, reuse messy codes.


If you can find a John Resig, use his/her stuffs.

If you can't, at least make and keep things simple for yourself and, above all else, for your customers.

1 comment:

  1. We wish you had better technical ability, or better still, better more capable hands to help you materialize your visions.

    Don't give up easily. Technicians who share your visions will come sooner than you expected!!!

    ReplyDelete

A Tip for Job Search: Gold Rush Skills

  If you need to make some money very quickly, what would you do? Your answer points to the kind of problems you can solve. They give you so...