views:

73

answers:

3

There is a custom control in my Silverlight application, which is put on the canvas about one thousand times. I'm concerned about the size of a XAP file of this app.

Will XAP file contain explicitely the names of this control in the same quantity? Will I reduce the size of the XAP file by changing the name of the custom control from, say, 10 letters to only 2 letters. How I can calculate the impact of the length of the class names on the final size of the XAP file?

+1  A: 

How I can calculate the impact of the length of the class names on the final size of the XAP file?

Simple answer: you could test it. Build your XAP file, rename the class, rebuild the XAP file, and see what the size difference is, if any.

I'd expect the name of the class to only occur once in the metadata, but if you're giving long names to the instances in the XAML, that may make a difference.

Jon Skeet
Yes, testing gave answer. Shortening that class name from 11 letters to 2 ones reduced the size of unzipped XAP folder only by 9k out of 336k, the zipped XAP remained the same size - 79k. Thanks for encouraging me to find out it by testing, I should develop good habits :)
rem
+1  A: 

A XAP file is just a ZIP file containing your compiled binaries. Your XAML files are embedded as resources in those compiled binaries.

So yes - the length of the name of your control will affect the file size of your XAP file.

How much is a different question. The XAP file is a compressed ZIP file. As an example I have a XAP file with 2 DLLs in. One compressed down from 282k to 94k, the other from 46k to 16k.

I would worry more about why your control appears 1000 times in a single page however. Surely there must be a better way of doing this. Perhaps even doing it in code would be easier/better?

samjudson
Yes, you were right. And special thanks for pointing out the possible way of trying to realize it in code. I didn't try it so far, but I will. +1
rem
+1  A: 

If size is important to you I think you are worrying about the wrong thing. You are more likely to include unused code, or DLLs, or large resources, than have names that are too long. Remember the file is zipped and text compression is very good so the effect of repeating the same long control name 1000s of times is minimal.

Also don't forget to re-zip your XAP files with better zip software (as the zip compression you get in XAP files built by Visual Studio is not optimal!)

You are much better off worrying about progressive loading as most Silverlight apps out there are way too bulky (and take way more than the expected/recommended 8 second attention span of most web-users).

Enough already
Yes, you were right. Shortening of names gave insignificant effect. Much more effective was to get rid of useless DLLs. Thanks, +1
rem