开发者

VB/VBA Variable Declaration Coding Standard - White Space

开发者 https://www.devze.com 2022-12-11 10:30 出处:网络
What is the signi开发者_运维技巧ficance of declaring variables in VB/VBA like so: Private m_sNameAs String

What is the signi开发者_运维技巧ficance of declaring variables in VB/VBA like so:

Private m_sName         As String
Private m_lAge          As Long

As opposed to;

Private m_sName As String
Private m_lAge As Long

I am working on a project which up to now uses the latter, and has done since long before I joined the project. Two new developers have joined the team and have begun to use the former. I have seen such pagination previously and wondered; what is its heritage and what advantages/disadvantages does it have? My own preference has always been the latter and remains so, as much for consistency as anything else.


In the days when code editors were much dumber and were little more the text editors it was easier to maintain the "column-style" (the former example) of code. However even then it could be a pain when changes would require manual re-orginisation of code.

But then intellisense and auto-formatting came along and made it really difficult to maintain the "column-style" formatting code. Change something in the line and the IDE automatically eliminated "unnecessary" white-space.

I'm all for readability but not to this extent, stick with latter style.


It's only a matter of readability. Multiple whitespaces in VB/VBA are ignored.

I'd use the former because it's more readable, but Visual Studio has its own formatting rules and will remove extra whitespaces, so I have to use the second form. :)


This is a coding convention from old C-days, where you had endless structs and you wanted to see the types and variable names starting in the same column. Do as you prefer!


Easier to read, in my opinion. You can clearly see the variable name and type in the former, whilst the latter becomes more difficult with more variable declarations.

0

精彩评论

暂无评论...
验证码 换一张
取 消