Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

coding standards

 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • 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?


 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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 Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic