Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating Member for labels: Any reason I should?

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!

like image 867
Refracted Paladin Avatar asked May 19 '09 18:05

Refracted Paladin


2 Answers

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.

like image 79
Joseph Avatar answered Oct 18 '22 23:10

Joseph


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.

like image 34
Joel Coehoorn Avatar answered Oct 18 '22 21:10

Joel Coehoorn