Helpful tips and hints by and for Melancholies

Brilliant deduction, Nostradamus. I hesitate to advise divorce, however, for the sake of the children. Surely, the only recourse here is Daily Self-sacrifice Recognition Rituals. Stuck forever with a Choleric. Egad. Let us bow our heads in empathy with our unfortunate Brother in Balance.

Today’s tip deals with JavaScript coding.

Do not write your functions this way:


var x;function foo{
if (x==5||x==8){
this.caption='Hello World'; return true;} else {
return false;}
}

Instead, write them this way:


var x;

function foo
    {
        if ( x==5 || x==8 )
            {
                this.caption='Hello World';
                return true;
            }
        else
            {
                return false;
            }
    }

Much better balance. Easier to read and maintain. Note that, for a complex function, you easily can match up your various delimiter pairs and code phrases.

<sigh>

Yes. The coding aesthetic is every bit as important to pogramming as proper style is to English. It would be long and painful to relate my experience coding a long project with eight of my friends back in high school. As brilliant as many of them were, they were phlegmatics to a man. There are few things quite so maddening as trying to combine the various functions and procedures written by seven or eight other people into a master module when the code is inefficiently displayed on the page and inappropriately documented.

No, documentation like:

is not what I would consider appropriate.

When the project was complete, I had no choice but to wade through several thousand lines of code and reformat everything.

It was a labor of love, suffice to say.