This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spaced out.

 
Richard Boren
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got a nitpick about my spacing, but I don't see the problem.
MyConstructor( String arg1, String arg2, String arg3, String arg4 )
{
 
Johannes de Jong
tumbleweed
Bartender
Posts: 5089
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
MyConstructor( String arg1 , String arg2 , String arg3 , String arg4 )
ps we use something else here in the Netherlands to space-out
 
Greg Harris
Ranch Hand
Posts: 1012
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it was really hard for me to get accustomed to that part of the spacing... especially in the "for" loops and "import" statements. however, i do see how it makes life a lot easier in the long run.
look at the example programs in the style guide if you are not sure about a particular spacing issue. i used it this morning to check on one of my programs. they do not specifically point out a couple cases that i wondered about, but those issues are included in the programs. i also look at the instructor's solutions to see how paul handled some of the things.
 
Richard Boren
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Johannes de Jong:
MyConstructor( String arg1 , String arg2 , String arg3 , String arg4 )

Strange, I've never been nitpick for this before. I guess the line "All identifiers are surounded with whitespace." from the Style Guide addresses this.

ps we use something else here in the Netherlands to space-out

And what would that be Johannes
 
Pauline McNamara
Sheriff
Posts: 4012
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just looked at the style guide again and noticed that spaces before semi-colons is sometimes used, sometimes not:
foo( i );
start();
int theTick = 5 ;
++count ;
Doesn't matter? Only if after an identifier? I think I've been playing it safe and always used it, so haven't gotten picked...
 
Michael Matola
whippersnapper
Ranch Hand
Posts: 1817
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The spacing issue that I stumbled over was something like this
if ( !done )
which according to the style guide should be
if ( ! done )
But I stared and stared and couldn't see it. Read through the style guide again. Resubmitted and got the same nitpick back. The nitpick was "Spacing!" -- When I finally saw the problem, I asked Marilyn if the exclamation point in the nitpick was a special clue, but she said no.
 
Greg Harris
Ranch Hand
Posts: 1012
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you think about it, Richard, your programs must be really good and Marilyn is digging for something to nitpick! i think i got away with it a few times as well.
 
Michael Matola
whippersnapper
Ranch Hand
Posts: 1817
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pauline McNamara:
Just looked at the style guide again and noticed that spaces before semi-colons is sometimes used, sometimes not:
<snip>
Doesn't matter? Only if after an identifier? I think I've been playing it safe and always used it, so haven't gotten picked...

Me too. I've been putting a space in before semi-colons regardless of what comes before the semi-colon, and noone's said boo.
It's taken some getting used to, but overall I really like the JavaRanch spacing conventions. (It makes my code so light and airy!)
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pauline McNamara:
Just looked at the style guide again and noticed that spaces before semi-colons is sometimes used, sometimes not:

foo( i );
start();

int theTick = 5 ;
++count ;

Doesn't matter? Only if after an identifier? I think I've been playing it safe and always used it, so haven't gotten picked...

The rule is spacing around identifiers (including between identifier and punctuation). Other spacing regarding punctuation is left to the discretion of the author.
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Michael Matola:
... The nitpick was "Spacing!" -- When I finally saw the problem, I asked Marilyn if the exclamation point in the nitpick was a special clue, but she said no.

Well, I guess it was a clue, but it was an unintentional one.
 
Greg Harris
Ranch Hand
Posts: 1012
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think the answer is that you should put a space anytime you have a vairable or identifier that can be changed...
int i = 0 ;
if( ! done );
because you can go back and change "done" to "finished"... but if you did not have a space, you would need to type the "!" as well. not really a big deal, but that is how i think about it.
obviously, you do not need a space after the ")" in an if statement or for loop because you are only changing what is inside the "( )".
the one that really got me was not putting a space after an import statement.
[This message has been edited by Greg Harris (edited July 16, 2001).]
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Greg Harris:
i think i got away with it a few times as well.

I'm human, too. Sometimes I miss stuff. That is not necessarily a good thing for the student.

[This message has been edited by Marilyn deQueiroz (edited July 16, 2001).]
 
Greg Harris
Ranch Hand
Posts: 1012
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oops... now i'm busted! i knew i shouldn't have posted that.
 
Manju Jain
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I must be the Number One[ dubious rank ] 'spacing' offender. I am doing Servlets-2 and still get rapped around for spacing issues. I am
sorry Marilyn , it does make me feel guilty about your unnecessary workload. I take care of spacing and stuff only when
sending email. I am in a hurry to complete the program first.
I am learning, I swear because of resubmitting assignments.
 
Johannes de Jong
tumbleweed
Bartender
Posts: 5089
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Greg Harris:
oops... now i'm busted! i knew i shouldn't have posted that.

Man your next attempt is gone be checked for spacing like you cant believe
 
Paul Ralph
Ranch Hand
Posts: 313
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm always getting busted for spacing.
I'm human, too. Sometimes I miss stuff.

Not on my assignments.
Paul R
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic