Archive for December, 2008
Installing Silverlight2 Tools for Visual Studio
I was talking with a friend of mine a couple of days ago about the future of web development and XAML specifically when he made the comment about the tools not being available for the average developer.
I said that I was pretty sure the tools were available now for Visual Studio. This morning, I went looking and sure enough the tools are available so I thought I’d download them and install them. And while I’m at it, I’ll write about the experience.
What is the global keyword in CSharp?
During the Christmas break, I received the following question:
What does C# global:: actually do? Code example, from table adapter code:
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] [global::System.Serializable()] [global::System.ComponentModel.DesignerCategoryAttribute("code")] [global::System.ComponentModel.ToolboxItem(true)] [global::System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedDataSetSchema")] [global::System.Xml.Serialization.XmlRootAttribute("AutoTwitDataSet")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.DataSet")] public partial class AutoTwitDataSet : global::System.Data.DataSet {
Extracting Methods
I once knew a programmer who had us all fooled into thinking he was the most organized programmer on the planet. When he left at night, his desk looked like he had never even been to work. When we did code reviews, his code was nicely formatted, there wasn’t a duplicate line of code anywhere.
Aside from the look of his code, he knew his stuff too. And this is back in the day when code editors were only slightly better than notepad… at least compared to today’s tools.
When he left and we started maintaining code he had written we found that only the code he had to show us was pretty. The rest of his code looked like all of our code.
But today, the amount of time it takes to keep your code looking nice is trivial thanks to some macros that Microsoft has built into Visual Studio. One of those macros is the refactoring macro called, “Extract Method.”
What’s it do?
Volatile variables and CSharp threads
The volatile keyword is a convenience keyword for those who need to access member variables of a class or structure in multi-threaded conditions.
Again, since this is an advanced CSharp concept this is probably something that most of you will not need to worry about using, especially in ASP.NET. However, there have been times when I’ve used multi-threading in an ASP.NET application (for screen scraping performance) so it is not completely out of the realm of possibility for you to need to know something about how to do multi-threaded programming. If you do, you’ll be glad you learned about the volatile keyword.
The "Double Submit" Issue from the Server Side
There are many times when you might want to ensure that a user only submits information to your system once. The most common, of course, is when you are collecting credit card information for a purchase. But there are other times as well.
The most common way of dealing with this is by using JavaScript to disable the submit button. Since most people using the web have JavaScript enabled, this works 99% of the time. But there are people who are so paranoid that they have turned off JavaScript and there are people browsing now with hand held devices that don’t support JavaScript (yet). This means we must also protect ourselves from the double submit issue on the server side.