Just a little question bout brackets.

Discussion in 'Spigot Plugin Development' started by avighnash, Jun 21, 2016.

  1. Hello! I recently switched to IntelliJ, and I noticed something, and wanted to as if it is okay. Sometimes, IntelliJ turns code like
    Code (Text):
     public LeagueDemote(Command parent) {
            super(parent, "demote");
    Code (Text):
        public LeagueDemote(Command parent) { super(parent, "demote"); }
    and I just wanted to ask, is that okay? Is it bad if I do it the first way instead of the second way? Thanks!
  2. Makes no difference. You could theoretically write the biggest java application all in one line.
    • Agree Agree x 3
    • Like Like x 1
  3. I heard from a very experienced developer that the second option is a bad way to go, so I had no idea what I should do.
  4. It's all about style I guess, it doesn't make a difference but generally you should only do that if the code will only be one line.
  5. Just bracket styles, sort of like how people position brackets differently like this:

    if() {



    Except in your case your just putting it in a line cuz it's small m8
    • Like Like x 1
  6. It goes against the Java Conventions (see page 7). But it is perfectly legal, just makes it much harder to read in the end. Do yourself a favor and stick to the conventions. Getting yourself in this habbit will make it much easier for you when you decide to join a team based project like CraftBukkit/Spigot. ;)
    • Agree Agree x 2
  7. The reason it is doing this is to save space on your screen. Since it knows that it is a small section, it is compacting it.

    Edit: Click on one of the braces. It will format to the normally accepted view.
  8. IntelliJ has a feature called Code Folding. Basically what this does, is it folds your methods/fields that are very minimal, and just displays it as one line on your screen. If you do unfold it, however, you will see that it's the same as your previous methods, and will be formatted exactly the same. Just how the IDE works. You can disable it in the settings if you please.
  9. I know xD I figured that out.
    • Like Like x 1
  10. This is exactly what I was looking forward. I think you were the experienced developer that I saw say this on a thread before. And I find it ugly when it is all in one line :p
  11. Jesus that is such a nitpicky section. I literally hate how they say you aren't supposed to have an indent for your case grouping in a switch statement, it looks so ugly without the extra tab indent. I would literally disregard the entirety of that page, except for a few small things.
  12. Sadly, a lot of beginner devs feel the same as you. Luckily, some smaller projects dont require these conventions and make up their own. Most of them are pretty close to these, though, with minor differences like the one you just said. As long as the entire team is on the same page with the conventions they pick/set then its fine. Example being Spigot. They are more lenient on conventions than the Bukkit team was with pull requests. I saw many get denied in Bukkit because of the small things.

    And you have to remember, these are just really small projects. If you ever want to join up with a large project you're going to have to study the conventions they chose/set otherwise your work will never get included. Here's the convention the Linux Kernel uses if you ever wanted to get a PR accepted to it: https://www.kernel.org/doc/Documentation/CodingStyle ;)
    • Like Like x 1
  13. Yeah, that's just how it is lol. If you ever pursue a development career you'll see many different variations of the normal conventions that you'll have to follow. If you think it's nitpicky as a solo developer in the eyes of the community then it'll get interesting once you HAVE to follow conventions set by both your employer. Sometimes you'll hate it, other times you'll love it.
  14. As I like to say, Java is not space orientated.
  15. xD I knew you were going to reply lol, I saw your profile, and it said that you were viewing this thread.
    • Funny Funny x 1
  16. :3
  17. I'm used to following my team's conventions (I usually have to do same line curly brackets instead of my usual next line curly brackets), I was just noting that because Oracle is supposed to be setting the standard for Java conventions (aka a big deal). I don't think Google's Java conventions document ever talked about how switch statements should be indented. The main thing I agree with on that page is defining multiple different variables on the same line (unless they are the same type, which is usually fine).
  18. Believe it or not, that's not possible. A single method is limited to around 65535 bytes long.
  19. You still could write the biggest Java application in one line. You'll just need more than a main method then^^
  20. Dammit i somehow didn't think of that...