• 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

Style Guide questions (spaces, not indents; identifiers; operators)

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some questions on the Style Guide at JavaRanch . . .

1.1 I understand the reasoning behind not indenting, but am I really going to hit the space bar 24 times to "tab" over 6 times ? Or will I press and hold the space bar and hope to let up just at the right spot ?
I am pretty much in code all day long and when I first tried this here at the CattleDrive, I was like, "whoa, this is going to drive me nuts !" I program in Oracle Pl*Sql most of the time, some HTML / JavaScript, and this just hit me hard as way inefficient.

2. - Identifiers
Uh, what is an Identifier ? This might qualify as "there really ARE dumb questions", but I'm not relating to what exactly is an "identifier"

3.2 y+= 100 * x;

My question is not what does this mean (although I would like to know), but my question is why use cryptic language ? The style guide makes serveral mentions of "maintenance programming" so that writing easy to read code is a good thing. Seriously, even though I've dabbled in Java for a couple of years (like only my big toe ever got wet, not even the other toes), I still stare and this and say "I have no idea what this means".
 
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

William Peck wrote:
1.1 I understand the reasoning behind not indenting, but am I really going to hit the space bar 24 times to "tab" over 6 times ? Or will I press and hold the space bar and hope to let up just at the right spot ?



Most text editors will let you edit your preferences/settings so that when you hit tab it will insert n number of spaces instead.

William Peck wrote:
2. - Identifiers
Uh, what is an Identifier ? This might qualify as "there really ARE dumb questions", but I'm not relating to what exactly is an "identifier"



Examples of identifiers are: classes, interfaces, packages, constants, fields, local variables, methods, parameters, and constants

Basically things that you use to identify something else, if that made any sense whatsoever.
 
William Peck
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Katrina,

thank you.

re: spaces, tabs: it sounds like you do tabbing and not spaces

re: Identifiers: ok, gotcha, I think I got thrown off by "use letters ('A' through 'Z' ...) and didn't even read the next phrase ('a' through 'z'), so I was thinking ALL identifiers use CAPS to start when I knew that wasn't true.
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

William Peck wrote:Some questions on the Style Guide at JavaRanch . . .

1.1 I understand the reasoning behind not indenting, but am I really going to hit the space bar 24 times to "tab" over 6 times ? Or will I press and hold the space bar and hope to let up just at the right spot ?
I am pretty much in code all day long and when I first tried this here at the CattleDrive, I was like, "whoa, this is going to drive me nuts !" I program in Oracle Pl*Sql most of the time, some HTML / JavaScript, and this just hit me hard as way inefficient.



When you are using a font like Courier or another one that is not a proportional font (like Ariel), it's pretty easy to tell when something is aligned. In Notepad, for example, that is the default. Other text editors give you a choice (e.g. TextPad). Many editors default to 8 spaces per tab, so tabbing and then converting the tabs to spaces may or may not work for you. Many text editors will automatically insert the leading spaces on the next line once you have already lined up one line.

Some fancier text editors have formatting options.
 
William Peck
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Marilyn, ok, thanks for the advice. I guess I will just play around with things.
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just a suggestion: I'm using jEdit, and set the option so that pressing Tab inserts four spaces, and when I hit enter the cursor is positioned at the same indentation on the next line. jEdit "speaks Java" so when the file extension is .java the editor provides color-coded syntax highlighting, when you type a left paren the right paren is instantly generated, and when you type a left brace, your next <cr> generates the matching right brace.

There are lots of Java-sensitive editors out there, this one worked for me, basically intuitively (I never had to RTFM, though there are more features out there if I did so.)
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic