Why We (Me Included) Need to Stick To JavaScript Programming Style Standards

Posted by Peter Kellner on April 01, 2013 · 1 min read

 

I’ve listened multiple times to Douglas Crockford talk about the importance of following good programming style standards.  I try to normally, but this morning I got a little lazy with the following code:

store.sync({
    success: function() {Ext.Msg.alert("success")},
    failure: function(a,b,c) {…

I wrote this a while back and wanted to keep it short so I did not put the alert message on it’s own line.  Then, today I came along and decided to not have it execute the alert so I simply added a leading “//” giving me

store.sync({
    success: function() {//Ext.Msg.alert("success")},
    failure: function(a,b,c) {..

Well, of course it crashed my production deployment because I was again lazy and did not test.

Had I originally done it correctly as

store.sync({
    success: function() {
        Ext.Msg.alert("success")
    },…

I would have not been bitten today.

Just sayin…