Monday, December 3, 2007

Silverlight Best Practices

So in a web application from time immemorial the bottle necks have been the database access and the ability of the servers to server up whatever it is that is supposed to be servered. Granted there are things todo or not todo in Silverlight that affect usability and clientside perf but really its all about the server. For the most part the biggest 'gotcha' is usually making sure you are supporting the Xaml mime type and having reasonable archicture to support the expected load. All that aside there are some things you should avoid.

A-sync calls via Ajax or whatever are your friend. Why hold up the users experience to log something if you can just fire and forget. This will provide smoother and a more seamless experience for the user.

Use some reasonable coding conventions. It is more important to be consistent then wither or not to use Hungarian notation. Personally I like my script to look pretty much like my C# .NET code. That and considering main customer demographic of the clients of the company I work for... I'm feel safer using some nice stricked super OCD coding standard.

To keep the browser experience as uniform as possible among browsers it is a good idea to not todo things with the HTML DOM if possible and push things like timers etc into Silverlight.

In Xaml... don't stretch paths and videos. especially videos.

User techniques that simplify your code for example using a trinary operator.

In JavaScript use the prototype object declaration instead of writting a specific class. Object declared like this will be only maintain one reference in the global look up for the script engine nomatter how many instances are created. This way everyone is pointed at one base class instead of complete instances of every class N times.

If you drag and droping set none targets to IsHitTestable=false

dont dynamically add a bunch of stuff to the visual tree and leave it there if you not using it.

don't use windowless mode if you don't have to and if you do turn it off when not needed.

No comments:

Post a Comment