Hi,
I'm starting to dive into VS2008's Code Metrics and review the findings on a windows form app that we developed. We are using only Infragistics controls throughout the app. I'm finding that almost every UI page is getting very bad ratings due to the InitializeComponent sub. How can I minimize the impact of using Infragistics controls while still setting all of the properties that we need for each control? Any guidance you could give would be greatly appreciated!
Thanks!
Tami
(Sorry if I miscategorized this. I wasn't sure where to put it sent it wasn't control specific.)
Tami,
What kinds of errors are you getting? What version of the controls are you using? I just threw an assortment of our controls onto a form and set a few properties on them, but didn't get any noteworthy errors. Perhaps if you can shed a little bit of light on what you're doing and the problem you're encountering, I'll be able to look further into this.
-Matt
I'm not really sure what the concern is with the designer-generated code. The InitializeComponent method in my test scenario did get a Maintainability Index of 24, but this is also code that is automatically generated by the VS designer, and as such we have a very limited degree of what code is generated. The designer will also do strange things when serializing some appearance (for example a color can have multiple casts within the same declaration, such as "Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))))", which I would imagine might not be considered maintainable or efficient, but if you were to go in and manually change this yourself, it would get overwritten anyway the next time that you made a change in the designer.
Is there a particular issue that these metrics are causing? By my understanding, the metrics are just meant to be used as a guide to see where a development team might focus on unit tests and analysis since they can help point out complexities and dependencies, but with designer-generated code I would think this isn't as applicable (i.e. in InitializeComponent). To further this issue, if I use only .NET controls, I can add a TabControl, a few Labels, and a DataGridView to a form and I start off with InitializeComponent's Maintainability Index at 31. If I simply set a few color properties and a Dock property, I drop to 30. The more properties I set, the less "maintainable" this code is, only because I've done something that changes the controls from their defaults. The code that is generated is certainly less-than-maintainable if you look at it that way, but it is not meant to be manually edited.
Matt,
I am just using it as a guide. I noticed the ratings were low and was wondering if you guys had any suggestions for improvement. If you don't, that's fine. I thought I would check.
Thanks for your help,
If I came off as critical in my previous post, that was unintentional. I did a bit of research when writing up that post, and was simply "typing out loud" as to my thought process, both for you and anyone else who might have the same questions, so I was trying to provide any additional detail. I don't really have any other advice to offer on the matter, but please let us know if you encounter any issues related to this matter so that we can look into it.