12
ODXT
3y

Looking to update the way I write my code to follow:
- Coding Convention
- Standard Work
- Coding Standards
- Whatever other name they call it

And found this...

Comments
  • 2
  • 2
    @Codex404
    The site suggests that the following is incorrect:

    Function ()
    {
    ...
    }
  • 4
  • 4
    I've never preferred one format over the other and have never understood the pious devotion to either of them. They both work, so I've always simply followed whatever convention was already in place at the company or within an existing project...they both seem easy to read to me, so why does it matter?
  • 1
    @Codex404
    Well there are multiple ways which programmers use brackets. But I think that most devs use one of the two in the image.

    And every once in a while you'll see things like this, or reversed.
  • 2
    @FrodoSwaggins hmm I don't think I'm a good guy anymore :(

    But both seem fine to me, but your if statement horrifies me.
  • 2
    My eyes are fucking bleeding everytime I see this:

    some fucking shit()
    {

    }
  • 1
    Depends on language. I always put my curly braces on the same line in js and php but only sometimes in c/c++.
  • 2
    I like my curly brackets always on the same line, because the code then looks like this, which makes blocks easily readable

    ******
    *****
    ****
    ********
    *****
    ***
    *****
    ***
    **
  • 1
    I used to program with the { on a new line but the longer I programmed I began prefering it on the same line and now hate the look of the new line version. Technical both are fine and even IDEs don agree on which is better.
  • 0
    I program in Python and mainly just ad-lib random shit with list nested list comprehensions.
  • 0
    I believe this is not general coding advice but rather a coding guide for a specific project. And if whoever started the project decided on one way to do it, this is the right way to do it for this project.
    It is very bad if the code style changes mid-file just because another dev worked on it and pushed his own favourite style.
    Same thing applies to tabs/spaces.
    Use the Auto-Format of your ide (it is configurable, surprise!) and don't worry.
  • 2
    @TobyAsE
    Actually, this is from the Monodevelop website. Which is why I was surprised.

    I think the way you do, it should be project specific. Or team specific.
Add Comment