JaedenRuiner
Well-known member
- Joined
- Aug 13, 2007
- Messages
- 340
- Programming Experience
- 10+
Well,
I've seen other people's posts tagged with FxCop all around the place, and well I knew of it, and figured I'd give it a try. Some of its more helpful aspects were readily apparent, catching unused locals and private fields, etc, but it seems a bit ... picky about things that well, I don't think are worth the effort. For example, I tend to create a lot of constants for things, and like a good C/C++ programmer, i usually All caps my consts to signify visual right off the bat that this identifier is representing a constant, and FxCop complains about appropriate cases and such. Whatever.
A few warnings came up that seem to befuddle me, and in the end I'm not sure how to resolve the issue. Case and point: Array Constants. I like arrays. Simple, easy, and pretty straightforward, and used to be (though i'm not sure with regards to .Net) parallel to simple types in that they didn't have all that pesky object overhead.
The problem is that with VB it has always complained about declaring Constant arrays, as if there would never be any purpose to having a list of items that will never change and their inter-relationships would make sense to refer to them in an array, especially when utilizing Enumerated types as integral indicies:
Now, All of those SQL* are declared public constants in the same class, as the class was intended to be 100% static, or shared as it is called in VB. My idea is simply to have a repository of all the commands and strings etc related to SQL statements. (or at least a fair number of them for basic SQL syntax).
however, FxCop has indicated that this does not protect the individual elements of the array, and thus I cannot do this:
But I could do this:
If that is the case, what would be a good recommendation for designing this with the intended effect. I want a "readonly constant array". A static element that has x number of elements, and cannot be changed nor can its elements be changes. In C/Delphi these are utilized to reduce overhead of the application, as they are delegated to a reserved memory space of constant values, but so far in VB it has not seemed to react in a similar manner.
As a continuation, I will be continually posing other FxCop type issues that the online help is not too fully versed in explaining, as tragically, I come at all programming languages from the computer side not the human side, so I typically (as I'm sure has been evident) don't like a language telling me how to program the computer or forcing me into a narrow view of what these systems can do. However, I am aware that many language based optimizations do occur and perhaps the effect i want is just not evident in the traditional style of application development.
Thanks (one of these days I might actually call myself a VB.net programmer)
I've seen other people's posts tagged with FxCop all around the place, and well I knew of it, and figured I'd give it a try. Some of its more helpful aspects were readily apparent, catching unused locals and private fields, etc, but it seems a bit ... picky about things that well, I don't think are worth the effort. For example, I tend to create a lot of constants for things, and like a good C/C++ programmer, i usually All caps my consts to signify visual right off the bat that this identifier is representing a constant, and FxCop complains about appropriate cases and such. Whatever.
A few warnings came up that seem to befuddle me, and in the end I'm not sure how to resolve the issue. Case and point: Array Constants. I like arrays. Simple, easy, and pretty straightforward, and used to be (though i'm not sure with regards to .Net) parallel to simple types in that they didn't have all that pesky object overhead.
The problem is that with VB it has always complained about declaring Constant arrays, as if there would never be any purpose to having a list of items that will never change and their inter-relationships would make sense to refer to them in an array, especially when utilizing Enumerated types as integral indicies:
VB.NET:
Public Shared ReadOnly SQL_CMDS() As String = {SQLSELECT, SQLINSERT, SQLUPDATE, SQLDELETE,
SQLCREATE.Substring(0, SQLCREATE.Length - 6), SQLDROP, SQLTRUNCATE, SQLSELECT & " " & SQLINTO}
Now, All of those SQL* are declared public constants in the same class, as the class was intended to be 100% static, or shared as it is called in VB. My idea is simply to have a repository of all the commands and strings etc related to SQL statements. (or at least a fair number of them for basic SQL syntax).
however, FxCop has indicated that this does not protect the individual elements of the array, and thus I cannot do this:
VB.NET:
SQL_CMDS = New String {"",""}
VB.NET:
SQL_CMDS(2) = "Hello"
If that is the case, what would be a good recommendation for designing this with the intended effect. I want a "readonly constant array". A static element that has x number of elements, and cannot be changed nor can its elements be changes. In C/Delphi these are utilized to reduce overhead of the application, as they are delegated to a reserved memory space of constant values, but so far in VB it has not seemed to react in a similar manner.
As a continuation, I will be continually posing other FxCop type issues that the online help is not too fully versed in explaining, as tragically, I come at all programming languages from the computer side not the human side, so I typically (as I'm sure has been evident) don't like a language telling me how to program the computer or forcing me into a narrow view of what these systems can do. However, I am aware that many language based optimizations do occur and perhaps the effect i want is just not evident in the traditional style of application development.
Thanks (one of these days I might actually call myself a VB.net programmer)