-
-
So although I've been heads down, I have noticed that .NET 4.0 and the latest Visual Studio 2010 CTP have been released. There are alot of great things coming but one which may cause a little confusion based on it's name is CoVariance. Both C# and VB are getting CoVariance but what does that mean. Well let's start with generics. When teaching I like to introduce generics by saying “OK now this feature is called ‘generics’ but it’s all about specifics.” I then discuss how polymorphism allows us to generically handle an object but how that can introduce two issues (1. minor is boxing 2. major is loss of type checking - since everything is an object) What ‘generics’ allow us to do is to tell the compiler which specific type will be in a collection and that resolves both of those issues in our benefit. This is an abreviation of a full explanation and added simply to place CoVariance in context, since it deals strictly with generics.
Unfortunately one of the challenges with generics is that you can cast a List<string> into a method thats looking for a list of objects list<integer> and just allow the code to run against whichever generic collection containing either strings or ints you pass in. Now, even in VB6 it was not uncommon to have several different buttons connected to the same event handler. In fact if you have a grid or similar construct with embedded controls this is still a common pattern, where the event handler is told which row the event came from. The reason is very simple, each row will have a similar piece of code that differs only by which row should be impacted and you wouldn’t want to rewrite that code.
Similarly, you probably have several different collections each of which is associated with a specific type through a generic declaration. There will be certain actions that you want to take on any of those different specific collections. This new feature allows you to define a single method and tell it to execute on any of the generic collections which support it’s expected interface. The idea is you can have a single copy of your code that knows how to work generically with the different collections associated with different specific types, that you will pass it. The good news is the compiler can see the type information for every planned access and even do type checking for each different type, thus you get the power of a polymorphic object with all the compiler based safety of strong typing.
-
-
Although apparently the author of the article isn't a big fan - kudos to President Bush for allowing local park managers to decide whether or not to allow mountain bikes within the park. Note that this doesn't automatically grant Mountain Bike access throughout the park, but rather allows the local park manager who will be familiar with where such access is appropriate (away from endangered flora and fauna) to grant such access and generally manage that portion of the park. In terms of comparison to something motorized, mountain bikes are significantly lower impact (many of the damages associated with bikers are found with hikers - the only one that would really be different imho is erosion impact)
http://nbcsports.msnbc.com/id/27183753/wid/18298287/?GT1=45002
-
-
I ran into some code today which caught me off guard. In the event handler for the Exit menu item was the command:
Application.Current.Shutdown()
(Note I've omitted the ; for C# syntax vs VB)
Now traditionally I've always used:
Close()
(I've omitted the 'this' or 'me' as well as the ; for those looking for language specifics...)
So is there a difference and is one better? Well there is definitely a difference and in my opinion each is definitely better in a certain scenario.
The core similarlity is that both need to be called from your main application window thread in order to shut the application. Thus calling close on a dialog doesn't shutdown your application, although calling shutdown from your main thread even in a dialog will... each will also call all the appropriate events for closeing windows and disposing of objects.
The core difference comes down to how your main application thread responds to the events which are fired as it prepares to close. The Shutdown command is unstoppable the app will close regardless of what one of the event handlers attempts. However, the Window_Closing (in WPF) event allows you to update the status of the CancelEventArgs (e) to indicate that the shutdown should be prevented. Thus if for example the user asked to exit and then the app said "but you have unsaved changes Save, Continue, Cancel?" which is something typically caught in the Window Closing event (since it's triggered when you click that cute little X in the upper right corner to close your window).
The problem - if you've called Shutdown, it doesn't matter if the user says - "Cancel" your app is slamming down.
Thus unless you are attempting to handle a sudden error condition ("Must stop now to avoid corrupting data.") you probably want to rely on the Window.Close() method instead of the Application.Shutdown method.
-
-
Well in theory the correct title for the group is the ASP.NET Special Interest Group of the San Diego .NET Users Group, but that didn't flow in the post title. I'm speaking at their meeting on the 21st in relation ot SharePoint and ASP.NET. Here's the description of the session I'll be doing:
SharePoint and its feature enriched cousin Microsoft Office SharePoint Server (MOSS) are becoming a standard part of company web properties. As such ASP.NET developers need to understand how to create custom applications which can leverage this Microsoft product. This presentation is going to look at setting up a shared SharePoint and ASP.NET development environment. It will then look at debugging for custom workflow applications and examine a custom ASP.NET Web Service which leverages the OpenXML office document format to generate a Word document on the server and add that document into a SharePoint document library. The presentation will leverage the Sales Forecast OBA code base which is publicly available on CodePlex with a focus on the ASP.NET , Visual Studio 2008 and SharePoint integration.
The meetings are held at the Microsoft San Diego offices in La Jolla. For more information go to their website at:
http://www.sandiegodotnet.com/Meetings/ASPNETSIG/tabid/59/ctl/Details/Mid/387/ItemID/113/Default.aspx?selecteddate=10/21/2008
-
-
One of those things that just make me shake my head...
I have a computer I keep in the company domain. Someone or something (I don't know who or what and to be honest don't care enough to find out, just enough to document the insanity) appears to have created a policy either at the domain or on my machine that automatically resets the default printer to OneNote.
For starters this is bad because it means that even though I go to the effort to make Printer 'x' my default because it's close to my office, the next time I restart, I instead have my default printer reset to OneNote... which is pretty annoying.
But a better question is why given that I already have an electronic copy of whatever it is I want to print I would want to print it to One Note.... so I could have an electronic copy...
More importantly it pretty much kills all those nice print short cuts MS put on everything where I can with a single click print whatever I want to my default printer... but, nope doing that just causes my system to pause while OneNote starts - wasting my time - so I can shut OneNote - wasting my time - and go through the full multi-step process of selecting a printer - wasting, well you get the point.
I hate to think that it's just the act of installing OneNote that does this...
http://connect.microsoft.com/onenote/feedback/ViewFeedback.aspx?FeedbackID=363469
-
-
So after quite the busy Spring I needed some downtime so I haven't posted in a while. I was all set to restrart posting back in September with a post that will be coming online here shortly but although I had done the work, things got hectic and so posting was postponed.
Well it's time to get rolling again. I have the book I finished at the start of Summer coming out in the next couple weeks, I've got the cover article for this months SQL Server magazine, I'm speaking at the ASP.NET User group here in San Diego on the 21st, and then again at Code Camp in LA prior to PDC. I don't have a ticket to PDC, but if you want to offer me one I'd be happy to take be there.
So over the next day or so I'll get a nice technical post on Silverlight 2 Beta 2 in place and a short post on how I'm losing weight (and you can too :- ) and generally start things going here on the blog again.