Search code examples
coding-stylecode-formattingcurly-braces

What's the best format to write my functions in?


which format is best practice?

format A

function FunctionA () 
{
    while () 
    {
        >>some code<<
    }
    if ()
    {
        >>some code<<
    }
    else if ()
    {
        >>some code<<
    }
}

format B

function FunctionB () {
    while () {
        >>some code<<
    }
    if () {
        >>some code<<
    } else if () {
        >>some code<<
    }
}

Solution

  • It doesn't really matter, as long as you adhere to one style, and when in a project with multiple people agree on one style and all use that style.