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

 

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…

About Peter Kellner

Peter is a software professional specializing in mobile and web technologies. He has also been a Microsoft MVP since 2007. In addition, he's a multi-course video author at Pluralsight. To read more about Peter Kellner and his experience click here. For information about how Peter Kellner might be able to help you with your project click here.

Follow me:


Comments

  1. Peter Kellner says:

    Sadly, Sidney that is not quite accurate. I really did forget and I’m a stickler for them in general. normally I work with resharper in vs2012 and shows me when I forget which I appreciate. I wish it would not compile without them but that is probably asking too much.

  2. you didn’t forget a semicolon… you just decided not to use one

  3. Nuno Quintas says:

    Not at first. Only when you said on the next line that it crashed, e went back up a found it.

    Pretty easy to miss in a first glance, even easier when under stress.

    And this is the sort of stuff that makes me love IntelliSense.

  4. Peter Kellner says:

    hasn’t anyone noticed I forgot a semicolon?

Follow

Get every new post delivered to your Inbox

Join other followers: