File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes coding standards Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "coding standards" Watch "coding standards" New topic
Author

coding standards

Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

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

Joined: Jan 10, 2002
Posts: 61769
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

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

Joined: Jan 10, 2002
Posts: 61769
    
  67

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: coding standards