• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Style guide : Tradition calls for ...

 
Joyce Lee
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While working on the assignment, we need to conform to the coding style stated by the cattle drive. But I don't quite understand the reasoning given at section 2.2 Spacing.
In the table, under the "Reasoning" column, it says "Tradition calls for...". How did those traditional rules being established?
Joyce
 
Marilyn de Queiroz
Sheriff
Posts: 9065
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul (the author of the Style Guide) wants to know if you have ever watched the musical/movie "Fiddler on the Roof".
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh if I was a Java Guru, Ya ha deedle deedle, bubba bubba deedle deedle dum...
While I think the "double-click" reason given is silly, I do think that the spacing that the style guide provides greatly enhances readability of code. At work, we don't have such strict spacing requirements, so you get stuff like:
doSomeMethod(oneArg,twoArg,threeArg);
Makes me want to scream. Look how much nicer this is:
doSomeMethod( oneArg , twoArg , threeArg );
So screw tradition, just do it!!
Now, can our illustrious leader explain the whole Fiddler on the Roof reference? I thought the whole tradition stuff was based on all y'all being old fogeys and stuck in your ways.
 
Joyce Lee
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Written by Marilyn:
Paul (the author of the Style Guide) wants to know if you have ever watched the musical/movie "Fiddler on the Roof".


I watched this movie when I was a little kid. Can't remember the storyline.

Written by Jason:
doSomeMethod(oneArg,twoArg,threeArg);

Makes me want to scream. Look how much nicer this is:

doSomeMethod( oneArg , twoArg , threeArg );


I do agree that the code looks much nicer and readable with the spacing. But what I do not understand is why it is a bad example to have spacing for the cast:

(MyClass) v.get( 3 ); // a bad example given in Style Guide at 2.2

(MyClass)v.get( 3 ); // a good example given in Style Guide at 2.2

According to the Sun's style guide, it says "Casts should be followed by a blank space". I thought having spacing after cast will make the code more readable as well as for the "double-click" reason.

Joyce
[ June 18, 2004: Message edited by: Joyce Lee ]
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have no idea other than the one given (see old fogey comment). Honestly if I see code at work that does have the space between the cast, it irks me. Same thing with:
public void someMethod ()

That extra space just really bothers me for some reason. Must be all the brainwashing from this place. Now that you bring it up, I am curious why that is considered bad.
Sheesh, she's not even passed Java-1B and already stirring up trouble
 
Marilyn de Queiroz
Sheriff
Posts: 9065
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Fiddler on the Roof is all about tradition and the way it affects our lives.

Actually, the Style Guide was changed at one time from a cast that looked like this ( String )obj to one that looked like this (String)obj. Apparently in Paul's world up to the current time, his perception of the traditional handling of casting requires that there is no space between the closing paren and the object being cast.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may ask, how did this tradition start? I'll tell you - I don't know. But it's a tradition... Because of our traditions, everyone knows who he is and what God expects him to do.
- Tevye (a fiddler)

Of course, it's more impressive with the song that goes with it.
I thought the whole tradition stuff was based on all y'all being old fogeys and stuck in your ways.
That too.
That extra space just really bothers me for some reason. Must be all the brainwashing from this place.
Probably. For me it always stuck out as the one place Paul doesn't put a space that I would. Usually it's the other way around.
[ April 10, 2004: Message edited by: Jim Yingst ]
 
Mike Gershman
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oi vey!
Tevye was the dairyman and father, not the fiddler.
Typographic consistency is important in smoothly assimilating printed text. In the case of Java, I see a number of people promoting subtly different standards. For example, Kathy Sierra suggests that do ... while loops are always bad style. One of my professors threatened to reject any homework using the conditional operator. And the argument over whether { belongs on the same line as "if ( )" or on the following line seems endless. While these variations each have reasons, they eat into the benefits of standardization.
One stated defense is that working programmers must be prepared to adopt the style in use at their particular shops. However, people change jobs, they use code from other shops, and they read manuals.
I have not seen a convincing reason why everyone doesn't just get solidly behind the Sun standard until it is in universal use.
 
Warren Dew
blacksmith
Ranch Hand
Posts: 1332
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mike Gershman:
Typographic consistency is important in smoothly assimilating printed text.

Is it? Different publications use different styles; some indent paragraphs while others don't, and we seem to be able to switch between reading proportional fonts, and fixed fonts with and without serifs without too much difficulty. I can see your argument over the course of a function, or possibly even a file, but I see no reason why an entire code base, much less the entire world, has to standardize.
I have a style that improves my productivity by about 10% over the Sun style; a 10% hit is too big to take for the sake of abstract standardization.
 
Mike Gershman
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Speaking for myself, I found large printed documents (not code) using the fixed spacing sans-serif printing of the IBM 1403 printers notably harder to read.
As for your programs, the question is not how quickly you turn them out but how quickly and accurately the next programmer can understand and maintain your code.
 
Pauline McNamara
Sheriff
Posts: 4012
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mike Gershman:

As for your programs, the question is not how quickly you turn them out but how quickly and accurately the next programmer can understand and maintain your code.

hear! hear!
...or the next nitpicker, as the case may be
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic