Intended position of braces in Java?

Discussion in 'Programming' started by TurtlesBeast23, Nov 24, 2018.

  1. 2008Choco

    Junior Mod

    I know for a fact that @RubbaBoy has not made a half decent IDE. The perfect IDE doesn't exi-

    [​IMG]

    [​IMG]
     
    • Funny Funny x 4
  2. I think its also done to reduce file size.
    And I don't think it annoys modders *that much*.

    People using nms on 1.13 should instead pr a new api for what they do now with nms.

    </offtopic>
     
    #42 Janmm14, Dec 5, 2018
    Last edited: Dec 5, 2018
    • Agree Agree x 1
  3. foncused

    Moderator Patron

    [​IMG]

    In all seriousness, in general I use K&R 1TBS for Java - I like seeing the braces, and dislike when they are optionally omitted (short conditionals/loops etc.), and Allman adds too much vertical whitespace.
     
  4. As long as you consistent, it really doesn't matter. I'll include a quote from Linus Torvalds, that perfectly summarizes my thoughts on this:

    "I've said this before, and I'll say it again: a standards paper is
    just so much toilet paper when it conflicts with reality. It has
    absolutely _zero_ relevance. In fact, I'll take real toilet paper over
    standards any day, because at least that way I won't have splinters
    and ink up my arse."
     
  5. But this one doesn't seem like such a hot topic, is it? It's just a question, and there's a weird but clear answer; yes, you should, because the POSIX definition of a text file says every line ends with a newline character.
     
  6. It doesn't matter unless you want other people to read your code.
     
  7. 2008Choco

    Junior Mod

    You want to read your code, so it should matter. Future you will thank you.
     
    • Agree Agree x 1
  8. That is when you say fuck it and rewrite it.
     
  9. I think placing your braces correctly saves time over rewriting it every time.
     
  10. I hope you don't plan on getting a job in software engineering.
     
    • Funny Funny x 1
  11. Yeah
    Also

    Code (Java):
    public class MyClass{
        public void hi() {
            if(true){
                System.out.println("Hi");
            }
        }
    }
     

Share This Page