So recently there have been a lot of requests on how to make your buildings better in Minecraft, Ive decided to make a guide to help you guys out. Feel free to add stuff in the comments and Ill consider adding it to the post!
This blog post will have running account of the all the blog post I will be doing in this month related to SQL Server Wait Types and Wait Queues.
Large amounts of useful (and not so useful) data are available on the Web in the form of structured text such as XML and HTML, or even plain text, and in binary formats such as bitmapped images. An Android device will typically have system and 3rd-party utilities such as browsers and media viewers installed to deal with many of these automatically if you click on an appropriate link in a browser. However, Android has classes that allow us to access and manipulate these data streams directly from within an application, giving the programmer complete control over how the data are retrieved, used, and displayed.
via Web Data Streams I.
Since MVC has been released I have observed much confusion about how best to construct view models. Sometimes this confusion is not without good reason since there does not seem to be a ton of information out there on best practice recommendations. Additionally, there is not a “one size fits all” solution that acts as the silver bullet. In this post, I’ll describe a few of the main patterns that have emerged and the pros/cons of each. It is important to note that many of these patterns have emerged from people solving real-world issues.
I was working with WPF/Silverlight since March 2008 and learnt lots of things. I wrote lots of Articles on Silverlight and published in my Blog. Today I decided to share you some of the best practices you should follow while doing development in WPF/Silverlight. Hope, this will help you guys while writing XAML codes. Read and try to strict with the guidelines whenever you are modifying your XAML.
Feedbacks are always appreciated. Hence, don’t forget to leave your comments at the end. If you have any more points, please share it here. I will review them and add those here.
Update [08-Aug-2010]: On popular demand, I updated this post with some explanation on “Why?”.
Some of the XAML coding best practices mentioned below:
- Don’t use unnecessary “xmlns” namespaces in the XAML file. This overburdens the load time of the Silverlight page (If you are using Resharper, you can do this very easily as it will change the color of the unnecessary items to Grey).
- Don’t add same namespaces multiple times in a single XAML page. It screws up the XAML code at the time of maintenance and also loads the assembly namespace multiple times causing various memory issues at runtime.
- Use proper name for your “xmlns” namespace prefix. For example: xmlns:commonControls is more meaningful than xmlns:cctrl. This avoids multiple declarations of namespaces in future.
- Try avoiding “xmlns” namespace prefix name as “local”. Instead use “localControls” or “localConverters” etc. as per your namespace name. Using “local” will not give you proper meaning. In the same assembly there may be two or more namespaces (e.g. Controls, Converters etc.). In such case, it will be helpful for you to use proper prefix name to distinguish between them in proper way.
- When adding a control that has no elements inside it, better to close it by self-closing tag “/>” instead of the hard closing tag (</TAG>). This gives more cleaner XAML code.
- Remove all unnecessary resource keys if they are not in use. These increases the memory uses and you may sometime encounter some animation issues due to this. If you need it at later point of time, you are always welcome to add it.
- Don’t use extra panels (e.g. Grid, StackPanel, Canvas etc.) unless it is required.
- Always try to use Grid as your panel first and if you require other panels, use them. Grid has the flexible UI layout and thus resizing your application will have a great effect.
- Never try to give a name to all of your controls inside your Silverlight page as it takes unnecessary object creation at the time of load. Name only those elements which you want to use from your code behind and/or from your xaml. If you are using MVVM pattern, you can remove the naming of your controls in almost all the cases.
- Use the Visibility property of the controls instead of the Opacity property to hide the content. Opacity to zero makes the control to hide but takes space in both memory and the UI. Other side, the Visibility property collapses the control from the UI, thus making spaces for the other controls in the same place.
- Use proper formatting of your XAML code. This gives better look of code and also easy to maintain in future.
- Use comments in XAML whenever require. This is useful when you revisit the code after a long time or some other person comes to work with your XAML file.
- Try to use StaticResource instead of DynamicResource as it increases the performance and also it throws exceptions at development time. Hence, easier to identify the root cause.
- Remove unnecessary styles & storyboard animations if they are not require at all.
- Try to add your styles in a separate file if you want to share them across your application. If they are specific to a single page then add them in the page resource.