I’m fairly new to programming and from learning I have seen different ways of formatting code, comments, etc; and have been recommended on different techniques.
I mostly program in C#, C++, and Java so I want to know what is the the best way to layout code so that if other people where to go through it, they would be impressed by how simple and easy to understand it is.
The best rule to follow is: (and probably the only rule everyone will agree on)
Pick one style and stick with it. Always put your braces in the same place. Use similar naming conventions. Don’t mix tabs and spaces, etc…
That being said. It is also usually a good idea to try and follow the conventions already in place for a language.
When working on a team with people, make sure that you all agree upon a style and stick with it. If you don’t, often times one developer will reformat a file with their auto-formatter, and then you can have hundreds of little conflicts that were just caused by whitespace.