Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Reading Code Standard

Reply
Thread Tools

Reading Code Standard

 
 
subhabangalore@gmail.com
Guest
Posts: n/a
 
      01-29-2013
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.

 
Reply With Quote
 
 
 
 
Mikhail Vladimirov
Guest
Posts: n/a
 
      01-29-2013
Maybe official conventions from Oracle is a good starting point: http://www.oracle.com/technetwork/ja...nv-138413.html
 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      01-29-2013
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

 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      01-29-2013
On 1/29/2013 11:29 AM, http://www.velocityreviews.com/forums/(E-Mail Removed) 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




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
standard libraries don't behave like standard 'libraries' Sriram Srinivasan Python 13 11-12-2009 06:05 PM
What are the standard network functions provided in standard C? disappearedng@gmail.com C Programming 5 06-10-2008 08:57 PM
How to redirect a "system" standard output and standard error to avariable (Linux) Venks Ruby 5 12-06-2007 12:21 AM
add pexpect to the standard library, standard "install" mechanism. funkyj Python 5 01-20-2006 08:35 PM
How standard is the standard library? steve.leach Python 1 04-18-2005 04:07 PM



Advertisments