Hi! I'm an aspiring computer scientist with interests in quantum computing and distributed systems. In this blog, I write about the useful things I've learned during my programming journey.
I would argue that not using curly braces is fine, as long as you keep the condition and action on the same (short) line. For example, doing a quick check then returning does not need 4 lines when it should only take 1.
If the condition and action are too long to fit on one line, then curly braces should be used for clarity.
Thanks,
But I think in 2020 we don’t need to be sensitive about number of lines of the code anymore.
Being future-proof and having low maintenance cost that helps code quality is a little higher in priority.
Hi! I'm an aspiring computer scientist with interests in quantum computing and distributed systems. In this blog, I write about the useful things I've learned during my programming journey.
Yeah, That's right it is less visual cluttering.
But I think the other benefits of having brackets (as I mentioned in the post) outperforms that.
I'm all about building a structure in the code to decrease the chance of future mistakes or bugs.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I would argue that not using curly braces is fine, as long as you keep the condition and action on the same (short) line. For example, doing a quick check then returning does not need 4 lines when it should only take 1.
If the condition and action are too long to fit on one line, then curly braces should be used for clarity.
Thanks,
But I think in 2020 we don’t need to be sensitive about number of lines of the code anymore.
Being future-proof and having low maintenance cost that helps code quality is a little higher in priority.
One line statements have less visual clutter, so they can arguably be more maintainable than unnecessarily adding curly brackets everywhere.
Do you really need brackets around “if (x < 0) break;” ?
Yeah, That's right it is less visual cluttering.
But I think the other benefits of having brackets (as I mentioned in the post) outperforms that.
I'm all about building a structure in the code to decrease the chance of future mistakes or bugs.