+ 1
How do you format curly braces?
How do you format curly braces when writing code in C++ or any other programming language that uses curly braces this way? https://sololearn.com/compiler-playground/c3nvsNT4CImI/?ref=app Like that? (1) https://sololearn.com/compiler-playground/cF3Ul3hUUtqT/?ref=app Or like that? (2)
2 Respostas
+ 3
My personal preference is option 1.
When writing code within a team I follow the style used by the company. Sometimes I work on legacy code that used a different style than newer code. Then I will adapt to match the older style in the legacy code.
In my opinion consistency and uniformity are what make code readable more-so than any specific style.
+ 3
I also use style 1 for my own code.
And many text editors which have "code completion" feature will also use style 1.
Style 2 adds too many wasted lines which results in lot more scrolling unless you are using a text editor with "code collapse" feature.
But as mentioned, you will want to match style to what already there when maintaining/updating existing code.