When I write code, I try to group lines of similar code together, then leave a blank line and write another block.
I believe this contributes to the neatness and readability of the code.
I'm not a big fan of bunching stuff together without any line spacing. It looks like hell, it's hard to read and it's difficult to follow.
One of the teachers I had, downgraded one of my assignments because I had spaced my code logically. He said, 'When you have to read code all day in the real world, you won't put this line spacing in and you'll be thanking me." Of course, I never did and never will thank him.
Now that I'm in the real world, most of the code files I see that have absolutely no line spacing are poorly written and poorly thought out.
This is probably more prevelant in VB type languages than in C type languages, but the same concept applies.
Two questions come to mind:
Source Code Format means a form of computer program, or any portion thereof, written in a programming language employed by computer programmers that must be compiled or otherwise translated before it can be executed by a computer.
The C/C++ extension for Visual Studio Code supports source code formatting using clang-format which is included with the extension. You can format an entire file with Format Document (Ctrl+Shift+I) or just the current selection with Format Selection (Ctrl+K Ctrl+F) in right-click context menu.
Consistently using the same style throughout your code makes it easier to read. Code that is easy to read is easier to understand by you as well as by potential collaborators. Therefore, adhering to a coding style reduces the risk of mistakes and makes it easier to work together on software.
I follow Microsoft's Guidelines for C#.
Edit: The standard for C# is Don't fight the IDE. If you hit CTRL K+D
, the IDE will automatically put blank lines in between code sections.
To follow that up, if you look at C# sample code on MSDN or anywhere else, there's normally a blank line in between each logically placed group. So There will be a blank line after all your member variables, a blank line after each method, etc.
In response to the comments expressing shock and horror that I use an IDE for C# programming:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With