• 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

Howdie y'all

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I saddled up for the cattle drive and sent in my first assignment last night. Hope I come out nit free at the other end eventually

One quick question about the style guide though. Is there a good reason for the style guide to demand braces like this:
class BlahBlah
{
// cool code
}

instead of what sun thinks it should be and uses on all certification like this:
class BlahBlah {
// cool code
}

I personally like the first better, but in order to learn the sun way of doing things I was training myself to use (and dare I say it, like) the sun way of using the braces.
 
village idiot
Posts: 1208
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think its a matter of choice. Personally, I don't know why anyone would want to use the sun style over ranch style. It's much easier to identify blocks of code when the enclosing braces are aligned vertically, and the different elements of the code are placed in such a way as to visually represent the structure.
Besides, it's aesthetically more appealing!
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe that the JavaRanch Style Guide was actually written before the Sun Style Guide. Also, at least at that time, most of the developers that Paul (the author of the style guide) asked preferred the non-K&R style. Also, Paul's personal feeling is that ".. the K&R style of brace placement. It's focus is on saving precious bytes in the source file and on screen real estate. This is from an age when you would be lucky if you had a teletype terminal and 100k of disk space."

It is a debatable subject, turning, at times, almost into a "holy war".

One of the things the Cattle Drive focuses on is the ability to follow whatever style the employer may want to enforce, even if it seems totally stupid to the developer. (Hopefully the braces issue doesn't fall into this category)
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[MdQ]: I believe that the JavaRanch Style Guide was actually written before the Sun Style Guide.

Unlikely. Note the copyright dates on each. It may have been before Paul read the Sun guide. As I recall Paul has observerved that at the time he wrote it, Sun's style guide was not being used consistently for most of Sun's code. (In fact one might argue it's still not in many cases - but there's now a lot more consistency thaan there used to be.) Of course, the JavaRanch style guide had a whole lot of internal inconsistencies when I first saw it, and the code examples in the guide itself did not actually follow what the guide instructed. So that whole line of argument seem neither here nore there. Fortunately both (Paul's guide and Sun's) are much better now.

Also, Paul's personal feeling is that ".. the K&R style of brace placement. It's focus is on saving precious bytes in the source file

This is a straw man argument. It might have been very weakly valid 20 years ago; it's not remotely valid now. No one* on either side of the debate cares about the number of bytes used in whitespace.

* where "no one" would more properly be: an insignificant number of people, who may be safely ignored.

and on screen real estate.

This is the main actual issue of interest nowadays. Along with its sister issue, space on the printed page - which was the real reason why K&R was adopted in the first place. (Nothing about number of bytes.) Many of us find considerable value in being able to see the logic of a method all in one place, with no scrolling. I'm not going to go on about this - I just wanted to separate the real issue from the silly straw man which Paul provided.
 
Patrick van Zandbeek
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, like I said I prefer the cattle drive one better, it feels more natural to me and makes it easier to spot the coding blocks.

But I did learn myself to use the sun style so I would be used to it when I go to do the SCJP exam. Oh well, this way I get to get used to both, maybe I should put that on my resume? "Can use curly braces in multiple styles."
 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Patrick -

I agree with you and Carol - I prefer the Cattle Drive curly braces to the Sun ones (there are other parts of the Cattle Drive style guide that I don't like so much, but that's another thread some day). But just so you know, the SCJP code examples do not follow the Sun style guide at all - in fact, they're generally downright atrocious. I think the point on the exam is to format code in a way that is intentionally confusing. So the Sun style guide will definitely come in handy for the SCJD if and when you decide to go for that, but probably not for the SCJP. Since we don't use any particular style guide at work, I'm sort of picking and choosing the things I like best about both guides and trying to remain consistent. Anyway, long story short and all that...

Kristin
 
Patrick van Zandbeek
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Kristin,

I didn't know that. I do eventually plan on taking SCJD but that won't be any time soon, since SCJP will come first anyway, so I'll happily forget about the sun style guide for now then.
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[Kristin]: But just so you know, the SCJP code examples do not follow the Sun style guide at all - in fact, they're generally downright atrocious. I think the point on the exam is to format code in a way that is intentionally confusing.

In some cases yes, the SCJP format may be intentionally confusing. (And I would argue that any halfway decent Java programmer should be able to read either K&R or BSD style with no problem, regardless of which they prefer - both are common in the industry.) More commonly though, the code samples have been formatted specifically in order to fit into a very small allowed screen area. Which generally means removing newlines wherever possible. So you may see something like:

That's not because the exam authors prefer such a style; it's generally because they had to.

Having said that, I think you'll find that SCJP style (such as it is) is typically closer to Sun style than to Coop style.
[ September 03, 2005: Message edited by: Jim Yingst ]
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ahhh, why I love IDEA's CTRL-ALT-L.
 
Kristin Stromberg
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jim: In some cases yes, the SCJP format may be intentionally confusing...[snip]...More commonly though, the code samples have been formatted specifically in order to fit into a very small allowed screen area.



Good point... sometimes I forget that those evil test writers are not just out to get us!!!
[ September 02, 2005: Message edited by: Kristin Stromberg ]
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[Kristin]: sometimes I forget that those evil test writers are not just out to get us!!!

Oh, I didn't say that. But there are more interesting things to test people on than whether or not they can understand unusual brace structures.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Carol Murphy:
I think its a matter of choice. Personally, I don't know why anyone would want to use the sun style over ranch style. It's much easier to identify blocks of code when the enclosing braces are aligned vertically, and the different elements of the code are placed in such a way as to visually represent the structure.
Besides, it's aesthetically more appealing!



Sorry, I completely disagree. I'll leave it at that.

My main issue is that there should be one and only one standard in the Java World, so that everyone is using the same way. Well, since Sun created Java I would let them set the standard, which they have. So Everyone in the world should use it because Sun is the stake holder, creator, and the best to get it out to the entire Java World.

Our standard written at JavaRanch won't reach the entire Java World.

The purpose of standards is so that everyone can easily read other people's code and reduce the costs of maintenance. Everyone can get used to any style of "curly braces" that they want. Regardless of whether one's opinion is that one is more aesthetically appealing than the other, and someone has the complete opposite opinion.

I just want to cry. Can't we all just get along.

Mark
 
Carol Murphy
village idiot
Posts: 1208
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Of course we can all get along! Just admit that I'm right, and everything will be jake!
 
If you are using a wood chipper, you are doing it wrong. Even on this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic