Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #26464 > unrolled thread

Re: PRINTING DIAMOND SHAPE WITH LOOPS!

Started byjyothi.m1089@gmail.com
First post2013-11-01 01:30 -0700
Last post2013-11-29 12:48 -0500
Articles 20 on this page of 29 — 8 participants

Back to article view | Back to comp.lang.java.programmer

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: PRINTING DIAMOND SHAPE WITH LOOPS! jyothi.m1089@gmail.com - 2013-11-01 01:30 -0700
    Re: PRINTING DIAMOND SHAPE WITH LOOPS! rossum <rossum48@coldmail.com> - 2013-11-01 13:03 +0000
    Re: PRINTING DIAMOND SHAPE WITH LOOPS! Mike Amling <mamling@chaff.us> - 2013-11-01 09:59 -0500
    Re: PRINTING DIAMOND SHAPE WITH LOOPS! Roedy Green <see_website@mindprod.com.invalid> - 2013-11-01 18:32 -0700
      Re: PRINTING DIAMOND SHAPE WITH LOOPS! pchristor@yahoo.co.uk - 2013-11-12 05:21 -0800
        Re: PRINTING DIAMOND SHAPE WITH LOOPS! Lew <lewbloch@gmail.com> - 2013-11-27 15:57 -0800
          Re: PRINTING DIAMOND SHAPE WITH LOOPS! Arne Vajhøj <arne@vajhoej.dk> - 2013-11-27 19:21 -0500
          Re: PRINTING DIAMOND SHAPE WITH LOOPS! pchristor@yahoo.co.uk - 2013-11-28 17:45 -0800
            Re: PRINTING DIAMOND SHAPE WITH LOOPS! Arne Vajhøj <arne@vajhoej.dk> - 2013-11-28 21:10 -0500
              Re: PRINTING DIAMOND SHAPE WITH LOOPS! pchristor@yahoo.co.uk - 2013-11-29 03:03 -0800
                Re: PRINTING DIAMOND SHAPE WITH LOOPS! Joerg Meier <joergmmeier@arcor.de> - 2013-11-29 12:33 +0100
                  Re: PRINTING DIAMOND SHAPE WITH LOOPS! pchristor@yahoo.co.uk - 2013-11-29 09:01 -0800
                    Re: PRINTING DIAMOND SHAPE WITH LOOPS! Arne Vajhøj <arne@vajhoej.dk> - 2013-11-29 13:15 -0500
                      Re: PRINTING DIAMOND SHAPE WITH LOOPS! pchristor@yahoo.co.uk - 2013-11-29 17:06 -0800
                        Re: PRINTING DIAMOND SHAPE WITH LOOPS! pchristor@yahoo.co.uk - 2013-11-29 17:24 -0800
                        Re: PRINTING DIAMOND SHAPE WITH LOOPS! Arne Vajhøj <arne@vajhoej.dk> - 2013-11-29 20:59 -0500
                          Re: PRINTING DIAMOND SHAPE WITH LOOPS! pchristor@yahoo.co.uk - 2013-11-30 06:57 -0800
                            Re: PRINTING DIAMOND SHAPE WITH LOOPS! Arne Vajhøj <arne@vajhoej.dk> - 2013-11-30 10:31 -0500
                            Re: PRINTING DIAMOND SHAPE WITH LOOPS! Lew <lewbloch@gmail.com> - 2013-12-02 15:32 -0800
                              Re: PRINTING DIAMOND SHAPE WITH LOOPS! pchristor@yahoo.co.uk - 2013-12-04 03:45 -0800
                                Re: PRINTING DIAMOND SHAPE WITH LOOPS! Arne Vajhøj <arne@vajhoej.dk> - 2013-12-09 21:10 -0500
                              Re: PRINTING DIAMOND SHAPE WITH LOOPS! pchristor@yahoo.co.uk - 2013-12-05 00:15 -0800
                                Re: PRINTING DIAMOND SHAPE WITH LOOPS! Arne Vajhøj <arne@vajhoej.dk> - 2013-12-09 21:14 -0500
                    Re: PRINTING DIAMOND SHAPE WITH LOOPS! Joerg Meier <joergmmeier@arcor.de> - 2013-11-29 19:58 +0100
                      Re: PRINTING DIAMOND SHAPE WITH LOOPS! pchristor@yahoo.co.uk - 2013-11-29 17:12 -0800
                        Re: PRINTING DIAMOND SHAPE WITH LOOPS! Joerg Meier <joergmmeier@arcor.de> - 2013-11-30 02:55 +0100
                        Re: PRINTING DIAMOND SHAPE WITH LOOPS! Arne Vajhøj <arne@vajhoej.dk> - 2013-11-29 21:01 -0500
                        Re: PRINTING DIAMOND SHAPE WITH LOOPS! Lew <lewbloch@gmail.com> - 2013-12-02 15:31 -0800
                Re: PRINTING DIAMOND SHAPE WITH LOOPS! Arne Vajhøj <arne@vajhoej.dk> - 2013-11-29 12:48 -0500

Page 1 of 2  [1] 2  Next page →


#26464 — Re: PRINTING DIAMOND SHAPE WITH LOOPS!

Fromjyothi.m1089@gmail.com
Date2013-11-01 01:30 -0700
SubjectRe: PRINTING DIAMOND SHAPE WITH LOOPS!
Message-ID<ecaee893-0ad6-48a6-b345-24a33436b4df@googlegroups.com>
On Wednesday, August 25, 2004 11:59:37 AM UTC+5:30, Liz wrote:
> "Hal Rosser" <hmrosser@bellsouth.net> wrote in message
> news:4wTWc.18629$cx.18110@bignews4.bellsouth.net...
> >
> > "Jay Dean" <fresh1700@yahoo.com> wrote in message
> > news:bd7dee67.0408241759.3884e4e9@posting.google.com...
> > > I need simple nested loops (either for, or while) code for a method to
> > > print a diamond shaped stars for n stars, where n is odd.
> > >   Example. n=9 would produce
> > >
> > >         *
> > >        ***
> > >       *****
> > >      *******
> > >     *********
> > >      *******
> > >       *****
> > >        ****
> > >         *
> > >  I have STRUGGLED with this for over three days in a row and my head
> > > aches!
> > > I tried with nested loops, and conditions but the results were not
> > > encouraging.
> > > I am a novice in Java and need help with simple nested loops to
> > > construct this. Thanks in advance for your help !!
> > >
> > >  Jay Dean
> >
> > Jay,
> > Being a beginner at programming, it may be a good idea to plan it out
> first.
> > you typed out what you want your program to do, so you should make note of
> > what you did.
> > For instance, note that the number of spaces before the "*" starts at a
> > maximum value and decreases by one after each print.
> > Also note the number of "*"s increase from one to a maximum value - then
> > decreases by one to one.
> > You're on the right track of using nested loops - you need to increment
> one
> > value and decrement another value.
> > Its a good exercise in planning your app.
> > Use flowcharts to plan if it makes things clearer for you.
> > Plan first - then write the code.
> > Hope this helps
> > Hal
> >
> ---------------------
> 
> class Test7
> {
>   public static final void main( String[] args )
>   {
>     int n = Integer.parseInt( args[ 0 ] );
>     for ( int i = 1; i <= n; i += 2 )
>     {
>       for ( int k = 0; k < ( n - i ); k += 2 )
>         System.out.print( " " );
>       for ( int j = 0; j < ( ( i * 2 ) - 1 ); j += 2 )
>         System.out.print( "*" );
>       System.out.println( "" );
>     }
>     for ( int i = 1; i <= n; i += 2 )
>     {
>       for ( int k = 1; k < i; k += 2 )
>         System.out.print( " " );
>       for ( int j = 0; j <= ( n - i ); j++ )
>         System.out.print( "*" );
>       System.out.println( "" );
>     }
>   }
> }

can you please explain the logic of this program....

[toc] | [next] | [standalone]


#26466

Fromrossum <rossum48@coldmail.com>
Date2013-11-01 13:03 +0000
Message-ID<tr8779pscp80e5qr896kg4dudiu7evskrn@4ax.com>
In reply to#26464
On Fri, 1 Nov 2013 01:30:23 -0700 (PDT), jyothi.m1089@gmail.com wrote:

>> class Test7
>> {
>>   public static final void main( String[] args )
>>   {

       // This line reads in integer, n, from the args array.
>>     int n = Integer.parseInt( args[ 0 ] );

       // Loop from 1 to n stepping 2 each time. [*1]
>>     for ( int i = 1; i <= n; i += 2 )
>>     {

         // This loop prints out the leading spaces needed for this
row.
>>       for ( int k = 0; k < ( n - i ); k += 2 )
>>         System.out.print( " " );

         // This loop prints out the correct number of stars for this
row of the diamond.
>>       for ( int j = 0; j < ( ( i * 2 ) - 1 ); j += 2 )
>>         System.out.print( "*" );

         // Mark the end of a single row of printing. [*2]
>>       System.out.println( "" );
>>     }

       // This part I will leave for you to examine yourself, with a
little help.
>>     for ( int i = 1; i <= n; i += 2 )
>>     {
>>       for ( int k = 1; k < i; k += 2 )
           // Print leading space
>>         System.out.print( " " );
>>       for ( int j = 0; j <= ( n - i ); j++ )
           // Print star.
>>         System.out.print( "*" );
         // End of this line.
>>       System.out.println( "" );
>>     }
>>   }
>> }
>
>can you please explain the logic of this program....

Notes:

[*1] Can you see why the loop steps by two?  If not, then count how
many stars there are in each row of the diamond.

[*2] Note the difference between print() and println().

If you really cannot understand the program, then work through it on
paper, keeping track of all the variables by hand.  That will give you
more insight into how it does its work.

rossum

[toc] | [prev] | [next] | [standalone]


#26467

FromMike Amling <mamling@chaff.us>
Date2013-11-01 09:59 -0500
Message-ID<bdhtv3F578bU2@mid.individual.net>
In reply to#26464
On 11/1/13 3:30 AM, jyothi.m1089@gmail.com wrote:
 > On Wednesday, August 25, 2004 11:59:37 AM UTC+5:30, Liz wrote:
 >> "Hal Rosser" <hmrosser@bellsouth.net> wrote in message
 >> news:4wTWc.18629$cx.18110@bignews4.bellsouth.net...
 >>>
 >>> "Jay Dean" <fresh1700@yahoo.com> wrote in message
 >>> news:bd7dee67.0408241759.3884e4e9@posting.google.com...
 >>>> I need simple nested loops (either for, or while) code for a method to
 >>>> print a diamond shaped stars for n stars, where n is odd.
 >>>>    Example. n=9 would produce
 >>>>
 >>>>          *
 >>>>         ***
 >>>>        *****
 >>>>       *******
 >>>>      *********
 >>>>       *******
 >>>>        *****
 >>>>         ****
 >>>>          *
 > can you please explain the logic of this program....

I haven't looked at the program, but looking at the diamond I see the 
first and last lines have one star, but the second and next-to-last have 
three stars and four stars respectively. I assume the four-star line was 
supposed to have three stars.

The number of lines to be written is n, so we might hope that an 
outermost loop would look like

for (int jj=0; jj<n; ++jj) {
   ...
   System.out.println();
}

The number of stars in each line is maximal, at n stars, when jj is 
around n/2, so I'm thinking something like ss=n-abs(jj-n/2), which has 
its largest value when jj=n/2 and decreases linearly as jj gets away 
from n/2. If ss is not exactly right, then let's fiddle with it. For 
n=9, jj=0, we want 1 star and ss is 9-5=4. For n=9, jj=4, we want 9 
stars and ss is 9-0=9.

The proposed ss needs to decrease faster as jj gets away from n/2. How 
about doubling the expression inside the abs()?
tt=n-abs(2*jj-n)
This decreases the number of stars by 2 for every step jj moves away 
from n/2. That's good. For n=9, jj=0, tt is 9-9=0. For n=9, jj=4, tt is 
9-1=8. I guess we just want to add 1 to tt to get the desired number of 
stars.
uu=n-abs(2*jj-n)+1

Adding an inner loop to print the stars, we get

for (int jj=0; jj<n; ++jj) {
   ...
   for (int kk=0; kk<n-Math.abs(2*jj-n)+1; ++kk) {
     System.out.print('*');
   }
   System.out.println();
}

We still want some spaces before the stars, and the number of spaces is 
minimal when jj=n/2 and increases as jj moves away from n/2. That suggests
vv=abs(jj-n/2)
For n=9, jj=0, vv is 4. For n=9, jj=4, vv is 0. Huh. That's exactly 
correct already.

Adding an inner loop to print the spaces, we get

for (int jj=0; jj<n; ++jj) {
   for (int kk=0; kk<Math.abs(jj-n/2); ++kk) {
     System.out.print(' ');
   }
   for (int kk=0; kk<n-Math.abs(2*jj-n)+1; ++kk) {
     System.out.print('*');
   }
}

I think that's correct and halfway understandable.

My overdeveloped sense of microefficiency wants to avoid the possibility 
that the JITC will produce code that evaluates n-Math.abs(2*jj-n)+1 more 
often than necessary, so if I were actually implementing this, I would 
write it as

for (int jj=0; jj<n; ++jj) {
   for (int kk=Math.abs(jj-n/2); --kk>=0; ) {
     System.out.print(' ');
   }
   for (int kk=n-Math.abs(2*jj-n)+1; --kk>=0; ) {
     System.out.print('*');
   }
}

Mike Amling
-- 
"Fiat lux" is the Big Bang in Latin.

[toc] | [prev] | [next] | [standalone]


#26470

FromRoedy Green <see_website@mindprod.com.invalid>
Date2013-11-01 18:32 -0700
Message-ID<mgl879dhdkql5i04bdaisghtkua8hvmq54@4ax.com>
In reply to#26464
On Fri, 1 Nov 2013 01:30:23 -0700 (PDT), jyothi.m1089@gmail.com wrote,
quoted or indirectly quoted someone who said :

>can you please explain the logic of this program....

run your program in an IDE with the trace option.  You can see it
working.
-- 
Roedy Green Canadian Mind Products http://mindprod.com
Unlike many machines, computers require no water once they are
manufactured.

[toc] | [prev] | [next] | [standalone]


#26499

Frompchristor@yahoo.co.uk
Date2013-11-12 05:21 -0800
Message-ID<c8f279f7-226f-42b6-8483-e9ce613ba353@googlegroups.com>
In reply to#26470
On Saturday, 2 November 2013 01:32:28 UTC, Roedy Green  wrote:
> On Fri, 1 Nov 2013 01:30:23 -0700 (PDT), jyothi.m1089@gmail.com wrote,
> 
> quoted or indirectly quoted someone who said :
> 
> 
> 
> >can you please explain the logic of this program....
> 
> 
> 
> run your program in an IDE with the trace option.  You can see it
> 
> working.
> 
> -- 
> 
> Roedy Green Canadian Mind Products http://mindprod.com
> 
> Unlike many machines, computers require no water once they are
> 
> manufactured.

Here is another option:

public static void main(String[] args) {
		
		int x=9;
		int m=x/2;
		StringBuilder str1= new StringBuilder(x);
		for(int i=0; i<m; i++){str1.append(" ");}
		str1.append("*");
		System.out.println(str1.toString());
		for(int j=1; j<x; j++){
			if(j<=m){	str1.deleteCharAt(m-j);
						str1.append("**");
			}else{
				str1.delete(m,m+2 ); str1.insert(0, " ");
			}
		System.out.println(str1.toString());
		}
	}

[toc] | [prev] | [next] | [standalone]


#26647

FromLew <lewbloch@gmail.com>
Date2013-11-27 15:57 -0800
Message-ID<2dd11538-00b2-42e0-8ddf-bdb6263478b4@googlegroups.com>
In reply to#26499
pchr...@yahoo.co.uk wrote:
> Here is another option:
> 
> public static void main(String[] args) {
> 
> 		int x=9;
> 		int m=x/2;
> 		StringBuilder str1= new StringBuilder(x);
> 		for(int i=0; i<m; i++){str1.append(" ");}
> 		str1.append("*");
> 		System.out.println(str1.toString());
> 		for(int j=1; j<x; j++){
> 			if(j<=m){	str1.deleteCharAt(m-j);
> 						str1.append("**");
> 			}else{
> 				str1.delete(m,m+2 ); str1.insert(0, " ");
> 			}
> 		System.out.println(str1.toString());
> 		}
> 	}

Seriously, dude?

Start by following the coding conventions, please.

Then we can help with the logic, should we be so bold.

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#26649

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-11-27 19:21 -0500
Message-ID<52968c88$0$298$14726298@news.sunsite.dk>
In reply to#26647
On 11/27/2013 6:57 PM, Lew wrote:
> pchr...@yahoo.co.uk wrote:
>> Here is another option:
>>
>> public static void main(String[] args) {
>>
>> 		int x=9;
>> 		int m=x/2;
>> 		StringBuilder str1= new StringBuilder(x);
>> 		for(int i=0; i<m; i++){str1.append(" ");}
>> 		str1.append("*");
>> 		System.out.println(str1.toString());
>> 		for(int j=1; j<x; j++){
>> 			if(j<=m){	str1.deleteCharAt(m-j);
>> 						str1.append("**");
>> 			}else{
>> 				str1.delete(m,m+2 ); str1.insert(0, " ");
>> 			}
>> 		System.out.println(str1.toString());
>> 		}
>> 	}
>
> Seriously, dude?
>
> Start by following the coding conventions, please.
>
> Then we can help with the logic, should we be so bold.

I am afraid that it was an answer not a question.

:-)

Arne

[toc] | [prev] | [next] | [standalone]


#26657

Frompchristor@yahoo.co.uk
Date2013-11-28 17:45 -0800
Message-ID<4dfd478f-58ef-4317-a313-7cddfa16d4b0@googlegroups.com>
In reply to#26647
On Wednesday, 27 November 2013 23:57:07 UTC, Lew  wrote:
> pchr...@yahoo.co.uk wrote:
> 
> > Here is another option:
> 
> > 
> 
> > public static void main(String[] args) {
> 
> > 
> 
> > 		int x=9;
> 
> > 		int m=x/2;
> 
> > 		StringBuilder str1= new StringBuilder(x);
> 
> > 		for(int i=0; i<m; i++){str1.append(" ");}
> 
> > 		str1.append("*");
> 
> > 		System.out.println(str1.toString());
> 
> > 		for(int j=1; j<x; j++){
> 
> > 			if(j<=m){	str1.deleteCharAt(m-j);
> 
> > 						str1.append("**");
> 
> > 			}else{
> 
> > 				str1.delete(m,m+2 ); str1.insert(0, " ");
> 
> > 			}
> 
> > 		System.out.println(str1.toString());
> 
> > 		}
> 
> > 	}
> 
> 
> 
> Seriously, dude?
> 
> 
> 
> Start by following the coding conventions, please.
> 
> 
> 
> Then we can help with the logic, should we be so bold.
> 
> 
> 
> -- 
> 
> Lew

What coding conventions are not being followed? 

[toc] | [prev] | [next] | [standalone]


#26658

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-11-28 21:10 -0500
Message-ID<5297f799$0$297$14726298@news.sunsite.dk>
In reply to#26657
On 11/28/2013 8:45 PM, pchristor@yahoo.co.uk wrote:
> On Wednesday, 27 November 2013 23:57:07 UTC, Lew  wrote:
>> Start by following the coding conventions, please.
>
> What coding conventions are not being followed?

Indentation, new lines and the usage of spaces are all
non standard.

Arne

[toc] | [prev] | [next] | [standalone]


#26662

Frompchristor@yahoo.co.uk
Date2013-11-29 03:03 -0800
Message-ID<0823db40-389b-4f41-8aa0-b3f283b4c7a9@googlegroups.com>
In reply to#26658
On Friday, 29 November 2013 02:10:32 UTC, Arne Vajhøj  wrote:
> On 11/28/2013 8:45 PM, pchristor@yahoo.co.uk wrote:
> 
> > On Wednesday, 27 November 2013 23:57:07 UTC, Lew  wrote:
> 
> >> Start by following the coding conventions, please.
> 
> >
> 
> > What coding conventions are not being followed?
> 
> 
> 
> Indentation, new lines and the usage of spaces are all
> 
> non standard.
> 
> 
> 
> Arne

I'm afraid the spaces are necessary.I would like to see your standard code, which contains no spaces, please post a short example.

I don't see how this answers the question about coding conventions. Is "non-standard" == "not following coding conventions" ??

[toc] | [prev] | [next] | [standalone]


#26664

FromJoerg Meier <joergmmeier@arcor.de>
Date2013-11-29 12:33 +0100
Message-ID<ckuxy8b2dzk6$.m1uk0hqaet5k.dlg@40tude.net>
In reply to#26662
On Fri, 29 Nov 2013 03:03:58 -0800 (PST), pchristor@yahoo.co.uk wrote:

> On Friday, 29 November 2013 02:10:32 UTC, Arne Vajhøj  wrote:
>> On 11/28/2013 8:45 PM, pchristor@yahoo.co.uk wrote:
>>> On Wednesday, 27 November 2013 23:57:07 UTC, Lew  wrote:
>>>> Start by following the coding conventions, please.
>>> What coding conventions are not being followed?
>> Indentation, new lines and the usage of spaces are all
>> non standard.
> I'm afraid the spaces are necessary.I would like to see your standard code, which contains no spaces, please post a short example.

Nobody said all spaces are unneccessary. Arne said that YOUR USAGE of them
is NON STANDARD.

> I don't see how this answers the question about coding conventions. Is "non-standard" == "not following coding conventions" ??

It is. The coding conventions set a standard of how to do these things. You
are doing them differently, which makes your code unpleasant to read for
those of us who do and are used to look at proper formatting.

Liebe Gruesse,
		Joerg

-- 
Ich lese meine Emails nicht, replies to Email bleiben also leider
ungelesen.

[toc] | [prev] | [next] | [standalone]


#26670

Frompchristor@yahoo.co.uk
Date2013-11-29 09:01 -0800
Message-ID<0905f2d3-dbe8-4fc4-8324-ae36262d42a0@googlegroups.com>
In reply to#26664
On Friday, 29 November 2013 11:33:42 UTC, Joerg Meier  wrote:
> On Fri, 29 Nov 2013 03:03:58 -0800 (PST), pchristor@yahoo.co.uk wrote:
> 
> 
> 
> > On Friday, 29 November 2013 02:10:32 UTC, Arne Vajh�j  wrote:
> 
> >> On 11/28/2013 8:45 PM, pchristor@yahoo.co.uk wrote:
> 
> >>> On Wednesday, 27 November 2013 23:57:07 UTC, Lew  wrote:
> 
> >>>> Start by following the coding conventions, please.
> 
> >>> What coding conventions are not being followed?
> 
> >> Indentation, new lines and the usage of spaces are all
> 
> >> non standard.
> 
> > I'm afraid the spaces are necessary.I would like to see your standard code, which contains no spaces, please post a short example.
> 
> 
> 
> Nobody said all spaces are unneccessary. Arne said that YOUR USAGE of them
> 
> is NON STANDARD.
> 
> 
> 
> > I don't see how this answers the question about coding conventions. Is "non-standard" == "not following coding conventions" ??
> 
> 
> 
> It is. The coding conventions set a standard of how to do these things. You
> 
> are doing them differently, which makes your code unpleasant to read for
> 
> those of us who do and are used to look at proper formatting.
> 
> 
> 
> Liebe Gruesse,
> 
> 		Joerg
> 
> 
> 
I may have a tab or a new line out of place but I wouldn't go as far as to say that its non standard, against coding conventions or unpleasant to read just because of that. The google browser seems to add spaces to it anyway.  

[toc] | [prev] | [next] | [standalone]


#26673

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-11-29 13:15 -0500
Message-ID<5298d9c6$0$300$14726298@news.sunsite.dk>
In reply to#26670
On 11/29/2013 12:01 PM, pchristor@yahoo.co.uk wrote:
> On Friday, 29 November 2013 11:33:42 UTC, Joerg Meier  wrote:
>> On Fri, 29 Nov 2013 03:03:58 -0800 (PST), pchristor@yahoo.co.uk wrote:
>>> On Friday, 29 November 2013 02:10:32 UTC, Arne Vajh�j  wrote:
>>> I don't see how this answers the question about coding conventions. Is "non-standard" == "not following coding conventions" ??
>>
>> It is. The coding conventions set a standard of how to do these things. You
>> are doing them differently, which makes your code unpleasant to read for
>> those of us who do and are used to look at proper formatting.

> I may have a tab or a new line out of place but I wouldn't go as far
> as to say that its non standard, against coding conventions or
> unpleasant to read just because of that. The google browser seems to
> add spaces to it anyway.

The convention says:

<quote>
Four spaces should be used as the unit of indentation.
</quote>

The code your posted did not follow.

The convention says:

<quote>
All binary operators except . should be separated from their operands by 
spaces.
</quote>

The code your posted did not follow.

That is observable facts, so you "I wouldn't go as far as to say" does
not make much sense.

The unpleasant part is subjective.

Arne



[toc] | [prev] | [next] | [standalone]


#26678

Frompchristor@yahoo.co.uk
Date2013-11-29 17:06 -0800
Message-ID<a05fd2eb-ccd8-45d3-9561-2ab7e85a5a84@googlegroups.com>
In reply to#26673
On Friday, 29 November 2013 18:15:30 UTC, Arne Vajhøj  wrote:
> On 11/29/2013 12:01 PM, pchristor@yahoo.co.uk wrote:
> 
> > On Friday, 29 November 2013 11:33:42 UTC, Joerg Meier  wrote:
> 
> >> On Fri, 29 Nov 2013 03:03:58 -0800 (PST), pchristor@yahoo.co.uk wrote:
> 
> >>> On Friday, 29 November 2013 02:10:32 UTC, Arne Vajh�j  wrote:
> 
> >>> I don't see how this answers the question about coding conventions. Is "non-standard" == "not following coding conventions" ??
> 
> >>
> 
> >> It is. The coding conventions set a standard of how to do these things. You
> 
> >> are doing them differently, which makes your code unpleasant to read for
> 
> >> those of us who do and are used to look at proper formatting.
> 
> 
> 
> > I may have a tab or a new line out of place but I wouldn't go as far
> 
> > as to say that its non standard, against coding conventions or
> 
> > unpleasant to read just because of that. The google browser seems to
> 
> > add spaces to it anyway.
> 
> 
> 
> The convention says:
> 
> 
> 
> <quote>
> 
> Four spaces should be used as the unit of indentation.
> 
> </quote>
> 
> 
> 
> The code your posted did not follow.
> 
> 
> 
> The convention says:
> 
> 
> 
> <quote>
> 
> All binary operators except . should be separated from their operands by 
> 
> spaces.
> 
> </quote>
> 
> 
> 
> The code your posted did not follow.
> 
> 
> 
> That is observable facts, so you "I wouldn't go as far as to say" does
> 
> not make much sense.
> 
> 
> 
> The unpleasant part is subjective.
> 
> 
> 
> Arne


It doesn't make sense to focus so much on some , not very important, whitespace formatting inconsistency. Almost everyone, including you, is guilty of breaking the conventions you've posted. 

[toc] | [prev] | [next] | [standalone]


#26680

Frompchristor@yahoo.co.uk
Date2013-11-29 17:24 -0800
Message-ID<e59eda88-8790-4cff-afd0-d498108c7f05@googlegroups.com>
In reply to#26678
On Saturday, 30 November 2013 01:06:39 UTC, pchr...@yahoo.co.uk  wrote:
> On Friday, 29 November 2013 18:15:30 UTC, Arne Vajhøj  wrote:
> 
> > On 11/29/2013 12:01 PM, pchristor@yahoo.co.uk wrote:
> 
> > 
> 
> > > On Friday, 29 November 2013 11:33:42 UTC, Joerg Meier  wrote:
> 
> > 
> 
> > >> On Fri, 29 Nov 2013 03:03:58 -0800 (PST), pchristor@yahoo.co.uk wrote:
> 
> > 
> 
> > >>> On Friday, 29 November 2013 02:10:32 UTC, Arne Vajh�j  wrote:
> 
> > 
> 
> > >>> I don't see how this answers the question about coding conventions. Is "non-standard" == "not following coding conventions" ??
> 
> > 
> 
> > >>
> 
> > 
> 
> > >> It is. The coding conventions set a standard of how to do these things. You
> 
> > 
> 
> > >> are doing them differently, which makes your code unpleasant to read for
> 
> > 
> 
> > >> those of us who do and are used to look at proper formatting.
> 
> > 
> 
> > 
> 
> > 
> 
> > > I may have a tab or a new line out of place but I wouldn't go as far
> 
> > 
> 
> > > as to say that its non standard, against coding conventions or
> 
> > 
> 
> > > unpleasant to read just because of that. The google browser seems to
> 
> > 
> 
> > > add spaces to it anyway.
> 
> > 
> 
> > 
> 
> > 
> 
> > The convention says:
> 
> > 
> 
> > 
> 
> > 
> 
> > <quote>
> 
> > 
> 
> > Four spaces should be used as the unit of indentation.
> 
> > 
> 
> > </quote>
> 
> > 
> 
> > 
> 
> > 
> 
> > The code your posted did not follow.
> 
> > 
> 
> > 
> 
> > 
> 
> > The convention says:
> 
> > 
> 
> > 
> 
> > 
> 
> > <quote>
> 
> > 
> 
> > All binary operators except . should be separated from their operands by 
> 
> > 
> 
> > spaces.
> 
> > 
> 
> > </quote>
> 
> > 
> 
> > 
> 
> > 
> 
> > The code your posted did not follow.
> 
> > 
> 
> > 
> 
> > 
> 
> > That is observable facts, so you "I wouldn't go as far as to say" does
> 
> > 
> 
> > not make much sense.
> 
> > 
> 
> > 
> 
> > 
> 
> > The unpleasant part is subjective.
> 
> > 
> 
> > 
> 
> > 
> 
> > Arne
> 
> 
> 
> 
> 
> It doesn't make sense to focus so much on some , not very important, whitespace formatting inconsistency. Almost everyone, including you, is guilty of breaking the conventions you've posted.

But thanks for the info anyway I will try to stick to this whitespace conventions in future.

[toc] | [prev] | [next] | [standalone]


#26682

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-11-29 20:59 -0500
Message-ID<529946a1$0$303$14726298@news.sunsite.dk>
In reply to#26678
On 11/29/2013 8:06 PM, pchristor@yahoo.co.uk wrote:
> On Friday, 29 November 2013 18:15:30 UTC, Arne Vajhøj  wrote:
>> On 11/29/2013 12:01 PM, pchristor@yahoo.co.uk wrote:
>>> I may have a tab or a new line out of place but I wouldn't go as far
>>> as to say that its non standard, against coding conventions or
>>> unpleasant to read just because of that. The google browser seems to
>>> add spaces to it anyway.
>>
>> The convention says:
>>
>> <quote>
>> Four spaces should be used as the unit of indentation.
>> </quote>
>>
>> The code your posted did not follow.
>>
>> The convention says:
>>
>> <quote>
>> All binary operators except . should be separated from their operands by
>> spaces.
>> </quote>
>>
>> The code your posted did not follow.
>>
>> That is observable facts, so you "I wouldn't go as far as to say" does
>> not make much sense.
 >
> It doesn't make sense to focus so much on some , not very important,
> whitespace formatting inconsistency.

Minor deviations from the standard coding convention does not
bother me.

Unawareness of the standard coding conventions does bother me.

>                                      Almost everyone, including you,
> is guilty of breaking the conventions you've posted.

Almost everyone has told a lie at some point in time, but that
is not a good argument for not recommending to speak the truth.

Arne



[toc] | [prev] | [next] | [standalone]


#26688

Frompchristor@yahoo.co.uk
Date2013-11-30 06:57 -0800
Message-ID<70b0e05c-3b47-40b2-a51f-5e0e61ce2a77@googlegroups.com>
In reply to#26682
On Saturday, 30 November 2013 01:59:59 UTC, Arne Vajhøj  wrote:
> On 11/29/2013 8:06 PM, pchristor@yahoo.co.uk wrote:
> 
> > On Friday, 29 November 2013 18:15:30 UTC, Arne Vajh�j  wrote:
> 
> >> On 11/29/2013 12:01 PM, pchristor@yahoo.co.uk wrote:
> 
> >>> I may have a tab or a new line out of place but I wouldn't go as far
> 
> >>> as to say that its non standard, against coding conventions or
> 
> >>> unpleasant to read just because of that. The google browser seems to
> 
> >>> add spaces to it anyway.
> 
> >>
> 
> >> The convention says:
> 
> >>
> 
> >> <quote>
> 
> >> Four spaces should be used as the unit of indentation.
> 
> >> </quote>
> 
> >>
> 
> >> The code your posted did not follow.
> 
> >>
> 
> >> The convention says:
> 
> >>
> 
> >> <quote>
> 
> >> All binary operators except . should be separated from their operands by
> 
> >> spaces.
> 
> >> </quote>
> 
> >>
> 
> >> The code your posted did not follow.
> 
> >>
> 
> >> That is observable facts, so you "I wouldn't go as far as to say" does
> 
> >> not make much sense.
> 
>  >
> 
> > It doesn't make sense to focus so much on some , not very important,
> 
> > whitespace formatting inconsistency.
> 
> 
> 
> Minor deviations from the standard coding convention does not
> 
> bother me.
> 
> 
> 
> Unawareness of the standard coding conventions does bother me.
> 
> 
> 
> >                                      Almost everyone, including you,
> 
> > is guilty of breaking the conventions you've posted.
> 
> 
> 
> Almost everyone has told a lie at some point in time, but that
> 
> is not a good argument for not recommending to speak the truth.
> 
> 
> 
> Arne

 I agree with you encouraging others to follow a standard coding convention but you must remember that to not follow it is not incorrect.
Comparing this to a truth or a lie for example is a prime example and is an incorrect analogy.

[toc] | [prev] | [next] | [standalone]


#26689

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-11-30 10:31 -0500
Message-ID<529a04d6$0$293$14726298@news.sunsite.dk>
In reply to#26688
On 11/30/2013 9:57 AM, pchristor@yahoo.co.uk wrote:
> I agree with you encouraging others to follow a standard coding
> convention

Actually - I did not do that.

>              but you must remember that to not follow it is not
> incorrect.

Correct and incorrect does not really apply to coding convention.

Code is either following coding convention or not. It is good
("best practice") to follow coding convention.

Code logic can be correct or incorrect.

>    Comparing this to a truth or a lie for example is a prime
> example and is an incorrect analogy.

It is good analogy in the sense that it is an example of
most people doing something does not make it acceptable.

Arne

[toc] | [prev] | [next] | [standalone]


#26704

FromLew <lewbloch@gmail.com>
Date2013-12-02 15:32 -0800
Message-ID<dbf4628f-3c4d-423d-90c6-754f8f7087e3@googlegroups.com>
In reply to#26688
On Saturday, November 30, 2013 6:57:33 AM UTC-8, pchr...@yahoo.co.uk wrote:
>  I agree with you encouraging others to follow a standard coding convention but you must remember that to not follow it is not incorrect.

Yes, it is.

> Comparing this to a truth or a lie for example is a prime example and is an incorrect analogy.

No, it is not.

Instead of being obstreperous, you should accept the coaching and thank those who offered it.

Your argumentativeness does not augur well for your continued progress.

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#26724

Frompchristor@yahoo.co.uk
Date2013-12-04 03:45 -0800
Message-ID<97b023b2-069a-445a-b219-d9840d301b18@googlegroups.com>
In reply to#26704
On Monday, 2 December 2013 23:32:20 UTC, Lew  wrote:
> On Saturday, November 30, 2013 6:57:33 AM UTC-8, pchr...@yahoo.co.uk wrote:
> 
> >  I agree with you encouraging others to follow a standard coding convention but you must remember that to not follow it is not incorrect.
> 
> 
> 
> Yes, it is.
> 
> 
> 
> > Comparing this to a truth or a lie for example is a prime example and is an incorrect analogy.
> 
> 
> 
> No, it is not.
> 
> 
> 
> Instead of being obstreperous, you should accept the coaching and thank those who offered it.
> 
> 
> 

If you want to understand the meaning of big words try looking up the meaning of convention. 

*PLonK*

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.java.programmer


csiph-web