Results 1 to 6 of 6
  1. #1
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Location
    Pittsburgh, PA
    Posts
    284
    Rep Power
    6

    Arrow Right-side for left curly braces

    If anyone other than yourself will ever* need to look at your code,
    please put curly braces at the end of their line. Like this:
    Java Code:
    class Test [COLOR="Red"][SIZE="5"]{[/SIZE][/COLOR]
        public boolean testInts(int a, int b) [COLOR="Red"][SIZE="5"]{[/SIZE][/COLOR]
            if (a== b) [COLOR="Red"][SIZE="5"]{[/SIZE][/COLOR]
            }
        }
    }

    Right-side left braces is standard Java style. It is used throughout the Java source code.
    It is specified in the Java Code Conventions. Here is one relevant section:
    7.2 Compound Statements
    Compound statements are statements that contain lists of statements enclosed in braces
    { statements }. See the following sections for examples.
    The enclosed statements should be indented one more level than the compound statement.
    The opening brace should be at the end of the line that begins the compound statement;
    the closing brace should begin a line
    and be indented to the beginning of the compound statement.
    Braces are used around all statements, even singletons, when they are part of a control
    structure, such as a if-else or for statement. This makes it easier to add statements
    without accidentally introducing bugs due to forgetting to add braces.
    The above section is just for compound statements.
    Sections elsewhere in the Conventions demonstrate right-side left braces throughout.

    If you think you have a better coding style,
    please consider whether your wisdom exceeds the collective wisdom
    of the folks who brought us Java. Perhaps you are smarter than most,
    but why should the world march in your parade when another,
    bigger parade is passing you by.

    *ever For instance, if you post your code here.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    It is nice when folks do this, but as for me, I'm ecstatic if they can simply use code tags, line up indentations, and don't left-justify everything. I guess I'll take what I can get.

  3. #3
    CodesAway's Avatar
    CodesAway is offline Senior Member
    Join Date
    Sep 2009
    Location
    Texas
    Posts
    238
    Rep Power
    6

    Default

    Is there a question, or is this in response to something, because it seems out of place where it is.

    1) Not everyone programs with the same style
    2) If they don't use the standard, they should expect that some people, like yourself, won't review their code
    3) If the OP is OK with this sacrifice, what's the problem?
    CodesAway - codesaway.info
    writing tools that make writing code a little easier

  4. #4
    CodesAway's Avatar
    CodesAway is offline Senior Member
    Join Date
    Sep 2009
    Location
    Texas
    Posts
    238
    Rep Power
    6

    Default

    Quote Originally Posted by Fubarable View Post
    It is nice when folks do this, but as for me, I'm ecstatic if they can simply use code tags, line up indentations, and don't left-justify everything. I guess I'll take what I can get.
    I agree, WAY too many times the code is poorly formatted, let alone "not standard".

    They must not be using Eclipse or Netbeans, since they both offer auto-formatting.
    CodesAway - codesaway.info
    writing tools that make writing code a little easier

  5. #5
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Location
    Pittsburgh, PA
    Posts
    284
    Rep Power
    6

    Default

    When reading posts, I read the code.
    Whether or not it is poorly formatted.

    Nowhere have I threatened to not read the code
    of those too green to know how to properly format their code.

  6. #6
    CodesAway's Avatar
    CodesAway is offline Senior Member
    Join Date
    Sep 2009
    Location
    Texas
    Posts
    238
    Rep Power
    6

    Default

    Same. What I do is if I can't read the code well, I throw it in Eclipse and let it format it and read it from there. It's especially useful for longer posts.
    CodesAway - codesaway.info
    writing tools that make writing code a little easier

Similar Threads

  1. [HELP]JSpinner Left Alignment
    By Hugo in forum AWT / Swing
    Replies: 7
    Last Post: 07-25-2011, 08:02 PM
  2. jasperreport-right to left
    By marjanzfz in forum Advanced Java
    Replies: 1
    Last Post: 09-15-2009, 03:06 PM
  3. Align left
    By britto_bicsjohn in forum AWT / Swing
    Replies: 2
    Last Post: 09-09-2009, 04:05 AM
  4. Deploy Jar Side By Side
    By Adrian in forum Eclipse
    Replies: 0
    Last Post: 04-11-2008, 02:09 PM
  5. menu in top left always
    By sschwinghammer in forum New To Java
    Replies: 2
    Last Post: 02-06-2008, 02:39 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •