52
s3id0n
6y

public void method()
{
// :(
}

instead of

public void method() {
// :)
}

bothers me more than it should

Comments
  • 0
    @ArcaneEye he meant
    void hello(void) {
    }
    Some C stuff.
  • 0
    Top one if I'm writing C and it's my own project.
  • 0
    This is preference thing not a bad thing. Stick to the topic. 😜
  • 2
    According to standard code convention the first is used in C#, the second in Java and several other languages.

    As I enjoy pointing out: Code style depends on language AND on team agreement, and consistence in and across projects is far more important than which style you use.
  • 0
    PHP:

    public function getUser(int $id): ?User
    {
    ...
    }

    I can't stand missing typehints, spaces or brackets in the wrong places, or snake_case.
  • 0
    @FrodoSwaggins

    Hey man I am 21 and currently catching up to speed with c++14 for my new job and wanted to know whether putting void in case of empty parameter list gives you any performance advantage or is it just for readability?
  • 0
    Ah, the good old C# notation.
  • 2
    I got less points in test doing like
    (){
    }

    My teacher sad correct way is like
    ()
    {
    }

    Thats unbelievable 🤦‍♂️
  • 0
    @FrodoSwaggins why adding void, in your opinion, is easier to read?
  • 0
    @Sweash well some languages have strict conventions and if you don't follow them, you lose points, don't see anything wrong with it.
  • 0
    @FrodoSwaggins yeah, I completely agree about auto keyword. It should be used only where the type is clearly clear. However, I don't see how this applies to the "void" keyword in function parameters.
  • 0
    @FrodoSwaggins + if you are writting C++, adding void will make the func compatible with C compilers. At least thats what SO says
  • 1
    I like the bottom one more since things start to make sense as to what belongs to what
  • 0
    The everlasting war between devs...
  • 0
    The first is standard in C#, so you'll have to live with that.
  • 0
    @filthyranter Doesn't matter as long as you're consistent ;)
  • 0
    @inaba If you're working on an open-source project done in C#, have fun with breaking standards.
  • 1
    @filthyranter Again, as long as you're consistent. That also mean you use what the reast of the project uses.

    If you want an example of how not to do this, the source code to .net is a pretty good example
  • 0
    @inaba Yeah, but if you have to use what the rest of the C# project uses, most of the time it's going to be the opening curly brace on a new line.
Add Comment