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


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

Reading Code Standard

Started bysubhabangalore@gmail.com
First post2013-01-29 08:29 -0800
Last post2013-01-29 17:55 -0500
Articles 5 — 5 participants

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


Contents

  Reading Code Standard subhabangalore@gmail.com - 2013-01-29 08:29 -0800
    Re: Reading Code Standard Mikhail Vladimirov <vladimirow@mail.ru> - 2013-01-29 09:18 -0800
    Re: Reading Code Standard Martin Gregorie <martin@address-in-sig.invalid> - 2013-01-29 20:23 +0000
      Re: Reading Code Standard Lew <lewbloch@gmail.com> - 2013-01-29 13:14 -0800
    Re: Reading Code Standard Arne Vajhøj <arne@vajhoej.dk> - 2013-01-29 17:55 -0500

#21836 — Reading Code Standard

Fromsubhabangalore@gmail.com
Date2013-01-29 08:29 -0800
SubjectReading Code Standard
Message-ID<3d960018-349d-456b-a533-c0d05d2c9aaf@googlegroups.com>
Dear Group,

The suggestions and the solutions given by the learned members of the group are very nice. Thank you for your kind time. 

Now as a new learner of the language, I am trying to consolidate my learning.

I want to read about good coding standards, and read some good codes in its various aspects. 

I was trying to search there are quite a few. But if you can kindly suggest.

Thanking You in Advance,

Regards,
Subhabrata.

[toc] | [next] | [standalone]


#21837

FromMikhail Vladimirov <vladimirow@mail.ru>
Date2013-01-29 09:18 -0800
Message-ID<2662e317-c022-4d76-b044-b672df976aa3@googlegroups.com>
In reply to#21836
Maybe official conventions from Oracle is a good starting point: http://www.oracle.com/technetwork/java/codeconv-138413.html

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


#21841

FromMartin Gregorie <martin@address-in-sig.invalid>
Date2013-01-29 20:23 +0000
Message-ID<ke9b3g$5so$1@localhost.localdomain>
In reply to#21836
On Tue, 29 Jan 2013 08:29:39 -0800, subhabangalore wrote:

> Dear Group,
> 
> The suggestions and the solutions given by the learned members of the
> group are very nice. Thank you for your kind time.
> 
> Now as a new learner of the language, I am trying to consolidate my
> learning.
> 
> I want to read about good coding standards, and read some good codes in
> its various aspects.
>
I think "The Practice of Programming" by Brian Kernighan and Rob Pike is 
well worth having. It describes good approached to naming, program layout 
and writing programs so they are easier to debug and maintain. There's 
not a lot about Java in it (its main focus is on C) but what it says is 
generally applicable to block structured languages: it gives examples in 
C, C++, Java, and Perl but its suggestions would be equally applicable to 
Python and Pascal.


-- 
martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |

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


#21842

FromLew <lewbloch@gmail.com>
Date2013-01-29 13:14 -0800
Message-ID<650990c3-38b0-4fef-9ccf-6ad907b52039@googlegroups.com>
In reply to#21841
Martin Gregorie wrote:
> subhabangalore wrote:
>> The suggestions and the solutions given by the learned members of the
>> group are very nice. Thank you for your kind time.
> 
>> Now as a new learner of the language, I am trying to consolidate my
>> learning.
> 
>> I want to read about good coding standards, and read some good codes in
>> its various aspects.
> 
> I think "The Practice of Programming" by Brian Kernighan and Rob Pike is 
> well worth having. It describes good approached to naming, program layout 
> and writing programs so they are easier to debug and maintain. There's 
> not a lot about Java in it (its main focus is on C) but what it says is 
> generally applicable to block structured languages: it gives examples in 
> C, C++, Java, and Perl but its suggestions would be equally applicable to 
> Python and Pascal.

As mentioned upthread, there are standards specific to Java.

They boil down to:
- Use camel case for identifiers except constant variables.
- Start variable and method names (except constant variables) with a lower-case letter.
- Start type names with an upper-case letter.
- Constant variables are spelled with all upper case, with word parts separated by underscores.
- Do not use underscores for any other identifiers, and do not use the dollar sign "$" in identifiers.
- Indent four spaces (or two) per indent level. DO NOT USE TAB CHARACTERS TO INDENT.
- Enclose all sub-statements (conditional blocks, loop blocks, initializers, ...) in braces.
- Use either K&R brace placement or put the opening brace on its own line aligned with the 
   control line. (The second approach is unofficial but widely used.)
- Declare static variables (constants first), then static methods, then instance variables, then 
   instance methods within a type. (Reasonable deviations exist.)
- Use fully descriptive variable names. (Avoid shorthand like 'int s = ...'.)
- Javadoc all elements accessible outside the type.
- Names should reflect algorithmic purpose, not data type.

There's more, but that'll get you started.

-- 
Lew

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


#21843

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-01-29 17:55 -0500
Message-ID<51085371$0$292$14726298@news.sunsite.dk>
In reply to#21836
On 1/29/2013 11:29 AM, subhabangalore@gmail.com wrote:
> The suggestions and the solutions given by the learned members of the group are very nice. Thank you for your kind time.
>
> Now as a new learner of the language, I am trying to consolidate my learning.
>
> I want to read about good coding standards, and read some good codes in its various aspects.
>
> I was trying to search there are quite a few. But if you can kindly suggest.

For a specific coding convention for Java go for the SUN (now Oracle)
Java Coding Convention.

For the reason behind using a coding convention go for a book
like Code Complete.

Arne



[toc] | [prev] | [standalone]


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


csiph-web