I had read in another post here on SO that when possible you shouldn't Generate Member's for labels. I was wondering what some potential DRAWBACKS to this would be?
Am I correct in saying that the benefit is increased performance? Anything else?
I have a winform app with 100's of labels. Is there any benefit to not generating members or is it only in Web Apps that you see a gain?
Thanks!
Readability. If you Generate Members for all your labels, but you aren't using them, then it makes your code harder to read. I know what most are thinking, it gets put in the designer file so it doesn't matter. Anyone who's done WinForms dev for any amount of time knows you WILL eventually have to go in there and find bugs (Fix the good ol' white screen of death).
Also, when you Generate Members for everything it will make your intellisense list very long, another negative.
This isn't only true for labels, this is true for any control you throw onto your Form. panels, grids, etc. If you never use them in your code base, consider changing the Generate Member to false since you don't use it anyway.
Label's have properties and other state that has to be held in memory. If your label never changes, you can save a little ram by not generating the member. Note that is not going to be the deciding factor in how your app performs, but that doesn't mean you shouldn't save a little ram now and then where you know you can.
It also keeps the label from uselessly cluttering the intellisense list for your form.
One big reason you should generate the member for your label is that it can make it easier to do localization.
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