• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

coding standards

 
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My two languages are C and java

in both of these languages it was considered very bad form to write.

but in javascript we are now being told to write

I can't get these answers from anyone here as they are just copying the style of other people out there (our framework provider for example)

why has this changed? or is it still bad but there is some horrible quirk of javascript that makes it a lesser of 2 evils?


 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Wendy Gibbons wrote:but in javascript we are now being told to write...


By who?

why has this changed?


Changed from what? Conventions for one language don't always translate to other languages.

or is it still bad


Why is it bad? or good?

but there is some horrible quirk of javascript that makes it a lesser of 2 evils?


It's completely moot. I see no advantage or disadvantage of one style over the other.

I do avoid putting multiple variables on a single line, though. I find that makes it hard to see what's going on.

And, of course I use proper indentation (missing from your examples) that clearly shows what's going on. To me, it's all about clarity rather than dogma. Do what makes the intent of the code clearest.
 
Wendy L Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:

Wendy Gibbons wrote:but in javascript we are now being told to write...


By who?

why has this changed?


Changed from what? Conventions for one language don't always translate to other languages.

or is it still bad


Why is it bad? or good?

but there is some horrible quirk of javascript that makes it a lesser of 2 evils?


It's completely moot. I see no advantage or disadvantage of one style over the other.

I do avoid putting multiple variables on a single line, though. I find that makes it hard to see what's going on.

And, of course I use proper indentation (missing from your examples) that clearly shows what's going on. To me, it's all about clarity rather than dogma. Do what makes the intent of the code clearest.



sorry the indentation was there, but the code tags were missing.

I have always worked in companies with coding style standards so dogma is my working life.

The "they" are the company experts who design our coding standards, the same experts that stopped us writing the above code in the java and C, but are now telling us to do it in javascript.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd say that if it helps you keep your job, follow their conventions.

But seriously, this is such a small point it's not really worth worrying over. I don't think there's anything wrong with either "style" as long as you format the code to be understandable and readable. That should, after all, be the point of any coding convention -- but often the intent gets lost in the dogma.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic